5
Answers

Printing to file is slow

A Repasky

A Repasky

12y
2.3k
1
This is running too slow.  I convert a VB program to C#.  The VB program takes 2 minutes and the C# takes 26 minutes.  I privacy reasons I can 
not send the WriteHistory. It build a StringBuilder and has a switch statement. There are 1.7 million records.
Any ideas on this would be appreciated.



arep



      public static void PrintHistory(SqlDataReader sourceReader, bool b)       {          using (StreamWriter sw = new StreamWriter(@"Extract\History.txt", b, Encoding.Default))          {             StringBuilder record = new StringBuilder();             while (sourceReader.Read())             {                record = Program.WriteHistory(sourceReader);                sw.WriteLine("{0}", record);             }          }       }
Answers (5)