C# .NET - Textwriter not writing to file - Asked By Anandh Ramanujam on 10-Jan-11 10:42 AM

Hi,

The textwriter is not writing anything to the file... Even no exception occurs.


TextWriter tw = new StreamWriter(@"C:\ErrorLog",true);
tw.WriteLine("================================================================");

tw.WriteLine("Process Begins at " + DateTime.Now.ToString());

Please can anybody help me in this regard

Thanks.

Please can anybody help me in this regardThanks.

Think you'll want a FileStream anyway to void contention issues - Robbe Morris replied to Anandh Ramanujam on 10-Jan-11 10:51 AM

using (FileStream f = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Write))
{
  using (StreamWriter w = new StreamWriter(f))
  {
  w.WriteLine("stuff");
  }
}