Fahmi Saha

Fahmi Saha

  • 1.9k
  • 57
  • 830

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#

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (2)