1
Answer

Asp.net MVC 5 or Asp.net core MVC

Pritesh More

Pritesh More

7y
206
1
Hello, 
I am trying to learn Asp.net mvc,i already started some mvc tutorial on youtube
https://www.youtube.com/watch?v=-pzwRwYlXMw&list=PL6n9fhu94yhVm6S8I2xd6nYz2ZORd7X2v 
, so i am little bit famaliar with it, but i am confused in different versions of mvc, now there is Asp.net mvc 5 as well as Asp.net core. so which version of MVC should I start to learn.
 
Answers (1)
0
Hirendra Sisodiya

Hirendra Sisodiya

NA 8.8k 3m 15y

hello Darnell
please look attachment, this is the sample applicaton that shows how to retrieve all selected filenames ,how to check file name( already exist or not) and how to save in database.... 
 
thanks
 
Please mark as answere if you like my answere
0
David Smith

David Smith

NA 1.9k 0 15y
what about this situation I mention earlier  ok I found a bug nfor some reason the filename is not switch to the next file , but i is incrementing

for (int i = 0; i <= openFileDialog1.FileNames.Length - 1; i++)
                        {
                            Console.WriteLine(openFileDialog1.FileNames[i]);
                            if ((myStream = openFileDialog1.OpenFile()) != null)
                            {
                                // Insert code to read the stream here.
                                Console.WriteLine(openFileDialog1.FileName);
                                myStream.Close();
                               
                            }

System.IO.StreamReader srReader = new System.IO.StreamReader(openFileDialog1.FileNames[i]);  ///// the i is increment correct, but the path still stay the same or the filename still stays the same, basically not reading the next file name.

when i step through the code I see each file in the array, but for reason its not moving to the next file name do you know why?


[0]=C:\ test.txt;
[1]=C:\test2.txt;
[2]=C:\test3.txt;

when i step through it shows all the selected files.

when i step through over the  
openFileDialog1.FileNames[i]

and out my cursor over openfiledialog1 each time whether the array of i is 1 , 2, or 3

the openfiledialog gives the same array path    which is [2]= C:\test3.txt

it doesnt go to the next filename it stay array [2], so there fore when when my  loop increment the second time, im going to get a error
in my mdb , because I cant have duplicate filenames
0
Hirendra Sisodiya

Hirendra Sisodiya

NA 8.8k 3m 15y

you can use this sample code for checking:
string strQuery = "Select count(*) from table1 where filename=" + filename;
OleDb.OleDbConnection Con =
new OleDb.OleDbConnection("ConnectionString");
Con.Open();
OleDb.OleDbCommand oledbcomm =
default(OleDb.OleDbCommand);
oledbcomm =
new OleDb.OleDbCommand(strQuery, Con);
OleDb.OleDbDataAdapter oledbAdap =
new OleDb.OleDbDataAdapter(oledbcomm);
DataSet ds = new DataSet();
oledbAdap.Fill(ds);
if (ds.Tables(0).Rows.Count > 0)
{
//File is already exist
}
else
{
//File is not exist
}
 
thanks
0
David Smith

David Smith

NA 1.9k 0 15y
ok I found a bug nfor some reason the filename is not switch to the next file , but i is incrementing

for (int i = 0; i <= openFileDialog1.FileNames.Length - 1; i++)
                        {
                            Console.WriteLine(openFileDialog1.FileNames[i]);
                            if ((myStream = openFileDialog1.OpenFile()) != null)
                            {
                                // Insert code to read the stream here.
                                Console.WriteLine(openFileDialog1.FileName);
                                myStream.Close();
                               
                            }

System.IO.StreamReader srReader = new System.IO.StreamReader(openFileDialog1.FileNames[i]);  ///// the i is increment correct, but the path still stay the same or the filename still stays the same, basically not reading the next file name.

when i step through the code I see each file in the array, but for reason its not moving to the next file name do you know why?


[0]=C:\ test.txt;
[1]=C:\test2.txt;
[2]=C:\test3.txt;

when i step through it shows all the selected files.

when i step through over the  
openFileDialog1.FileNames[i]

and out my cursor over openfiledialog1 each time whether the array of i is 1 , 2, or 3

the openfiledialog gives the same array path    which is [2]= C:\test3.txt

it doesnt go to the next file
0
David Smith

David Smith

NA 1.9k 0 15y
Ok I think I have it now, now I jt need help with the query checking the database for for existing textfile, if the textfile filename is there do not send if it not there send.

can you help with that
0
Hirendra Sisodiya

Hirendra Sisodiya

NA 8.8k 3m 15y

No..
but openFileDialog1.FileName will return only one file. 
 
you can use this code like this:
OpenFileDialog
openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title =
" Choose raw data files to extract!";
openFileDialog1.Multiselect =
true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{

if (openFileDialog1.FileNames.Length > 0)
{
// Insert code to read the stream here.
for (int i = 0; i <= openFileDialog1.FileNames.Length - 1; i++)
{

System.IO.
StreamReader srReader = new System.IO.StreamReader(openFileDialog1.FileNames[i]);
// place your another Code
//.....
//.....
 

}
//myStream.Close();
}
}
 
thanks
 
Please mark as answere if you like my answere
0
David Smith

David Smith

NA 1.9k 0 15y
hi got a question before i try the code do you think the problem is here when actually extracing from the file


 System.IO.StreamReader srReader = new System.IO.StreamReader(openFileDialog1.FileName);


0
Hirendra Sisodiya

Hirendra Sisodiya

NA 8.8k 3m 15y

Hello Darnell
use this code:
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title =
" Choose raw data files to extract!";
openFileDialog1.Multiselect =
true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
System.IO.
Stream myStream;
if ((myStream = openFileDialog1.OpenFile()) != null)
{
// Insert code to read the stream here.
for (int i = 0; i <= openFileDialog1.FileNames.Length - 1; i++)
{
Console.WriteLine(openFileDialog1.FileNames[i]);
}

myStream.Close();
}
}
 
thanks
Please mark as answere if you like my answere
0
David Smith

David Smith

NA 1.9k 0 15y
you cant use filenames as a method(); invalid



string[] Filename = dlg.FileNames();
//if you want in one string with ';' seperator you can use this
string AllFileNames = "";
for (int i = 0; i <= Filename.Length - 1; i++)
{
AllFileNames = AllFileNames + Filename(i) +
";";    invalid
}

0
David Smith

David Smith

NA 1.9k 0 15y
Selecting all works , but it when I hit open go check the mdb file it only send one, instead of all, how would i do the query to check to see if the files exist in a certain column.
0
David Smith

David Smith

NA 1.9k 0 15y
Ok I already had that , this is the code i have before, when I highlight all to send to the database it doesnt send all, it only send one file

                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Title = " Choose raw data files to extract!";
                openFileDialog1.Multiselect = true;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Stream myStream;
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        // Insert code to read the stream here.
                        Console.WriteLine(openFileDialog1.FileName);
                        myStream.Close();
                    }
                }

Im trying to understand the what you guys are doing differently, because have the same basically and its not working for me. Im going to post my code , maybe you can see where I going wrong. check the text file im attaching in the zip file
0
BangaruBabu Pureti

BangaruBabu Pureti

NA 629 82.5k 15y

hI,This Is The Code I written


if (this.openFileDialog1.Show
Dialog() == DialogResult.OK)
            {
                openFileDialog1.Multiselect = true;
   
                foreach (string fileName in openFileDialog1.FileNames)
                {
                    textBox1.Text = fileName;
                }
}

if U Want More Reference Check This Link It May Help U


http://stackoverflow.com/questions/1311578/opening-multiple-files-openfiledialog-c

Regards
BangaruBabu Pureti

0
Hirendra Sisodiya

Hirendra Sisodiya

NA 8.8k 3m 15y

Hello Darnell
try this:
 we can find all file names with the FileNames proerties, it is array type.
OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiselect =
true;
dlg.Filter =
"txt(*.txt)|*.txt";
dlg.ShowDialog();
string[] Filename = dlg.FileNames();
//if you want in one string with ';' seperator you can use this
string AllFileNames = "";
for (int i = 0; i <= Filename.Length - 1; i++)
{
AllFileNames = AllFileNames + Filename(i) +
";";
}
 
now you can check that file name is exist in database or not by simple query
thanks
 
Please mark as answere if you like my answere