How to read multiple .CSV files from a folder in c#? -


i writing console application reads multiple csv files specified folder using smartxls library. able read single file unable figure out how read multiple files. kindly, me this.

public void getdata()         {              int count = 0;              desktokens = new list<token>();              string directory = path.getdirectoryname(assembly.getexecutingassembly().location);             string path = path.combine(directory, @"c:\projects\product_usage_year.csv");              smartxls.workbook wb = new workbook();             wb.readcsv(path);              datatable dt = wb.exportdatatable();              string currenttype = string.empty;             string currentcategory = string.empty;              datarow dr;             (int = 1; < dt.rows.count; i++)             {                 dr = dt.rows[i];                 var tkn = new token();                  tkn.product_name = dr[0].tostring();                 tkn.product_version = dr[1].tostring();                 tkn.userid = dr[2].tostring();                 tkn.user_name = dr[3].tostring();                  desktokens.add(tkn);                 count++;                 console.writeline("read : " + count);                  console.writeline("    reading : " + tkn.product_name + "," + tkn.product_version + "," + tkn.userid + "," + tkn.user_name);              }         } 

below, "path" directory in csv files reside.

var files = directory.enumeratefiles("path", "*.csv"); foreach (string file in files) {     using (filestream fs = new filestream(file, filemode.open, fileaccess.read))     {         // use file stream read data.     } } 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -