2
Answers

read multiple csv data in c#

Guest User

Guest User

4y
3.7k
1
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)