Your Ad Here

Posted By

krisdb on 04/02/08


Tagged

c


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


WriteToLog


 / Published in: C#
 

  1. static void WriteToLog(string strMsg)
  2. {
  3. string strFilename = "C:\\logs\\Log_"+System.DateTime.Now.ToString("MM-DD-YYYY")+".log";
  4.  
  5. FileStream fsLog = new FileStream(strFilename, FileMode.Append, FileAccess.Write, FileShare.Write);
  6. StreamWriter swLog = new StreamWriter(fsLog);
  7. swLog.Write(DateTime.Now.ToString() + " ");
  8. swLog.WriteLine(strMsg);
  9. swLog.Flush();
  10. swLog.Close();
  11. }

Report this snippet  

You need to login to post a comment.