A Repasky

A Repasky

  • NA
  • 231
  • 179.9k

Printing to file is slow

Sep 18 2012 2:59 PM
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)