writing c# program result to csv file -


i have c# program compared 2 database tables , uploaded results table in database. started getting maxpackets error..which understanding uploaded results large.

my thoughts dump results csv file instead. have tried follow several examples, program stalls. have wrong?

{                 string filepath = @"c:\users\rena\documents\test.csv";                 string delimiter = ",";                  string[][] output = new string[][]                 {                     new string[] { "col 1 row 1", "col 2 row 1", "col 3 row 1"},                     new string[] {"col 1 row 2", "col 2 row 2", "col 3 row 2"}                 };                 int length = output.getlength(0);                 stringbuilder sb = new stringbuilder();                 (int index = 0; index < length; index++)                     sb.appendline(string.join(delimiter, output[index]));                  if (!file.exists(filepath))                  file.writealltext (filepath, sb.tostring())              } 

thanks!!

you might try write buffered stream. see if more clear:

void main() {      string filepath = @"c:\temp\test.csv";     string delimiter = ",";      string[][] output = new string[][]     {         new string[] { "col 1 row 1", "col 2 row 1", "col 3 row 1"},         new string[] {"col 1 row 2", "col 2 row 2", "col 3 row 2"}         //tried 2k here     };     int length = output.getlength(0);     stringbuilder sb = new stringbuilder();       using (filestream filestream = file.create(filepath))     {         using (bufferedstream bufferedstream = new bufferedstream(filestream))         {             using (streamwriter streamwriter = new streamwriter(bufferedstream))             {                 (int index = 0; index < length; index++)                     streamwriter.writeline(string.join(delimiter, output[index]));             }            }     }      if (!file.exists(filepath))      file.writealltext (filepath, sb.tostring());  } 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -