hi,
I have a program that can read CSV. How to make it loop to read CSV file and insert. Example one folder has 2 CSV file. The program will read 1.csv and insert. And then 2.csv and then insert. Please help me.
- DirectoryInfo info = new DirectoryInfo(@"C:\folder\apoo");
- FileInfo[] filess = info.GetFiles().OrderByDescending(p => p.LastWriteTime).ToArray();
-
- string latestfile = "";
- DateTime lastupdate = DateTime.MinValue;
-
- var connString = "path";
-
- foreach(FileInfo filess2 in filess)
- {
- if (filess2.LastWriteTime > lastupdate)
- {
- lastupdate = filess2.LastWriteTime;
- latestfile = filess2.Name;
- }
- Console.WriteLine("File : " + latestfile);
- Console.WriteLine("LWT : "+lastupdate);
- }