Guest User

Guest User

  • Tech Writer
  • 77
  • 13.9k

read multiple csv data in c#

Jul 13 2020 2:16 AM
Hi, i have question

How to write the code for read multiple csv file in a folder and display it in console ?
 
For right now, i can only do read one file for example: 
 
 string path = (@"C:\ipub\root\Book1.csv");
string[] lines = System.IO.File.ReadAllLines(path);
 
foreach (string line in lines)
 {
    Console.WriteLine(line);
    string[] columns = line.Split(',');

      foreach (string column in columns)
      {
        Console.WriteLine("Kandungan : " + column);
        }
 }
 
please help me, thank you
im using visual studio 2019,c#

Answers (2)