C c code for writing log to text file

From , 4 Years ago, written in C#, viewed 53 times.
URL https://pastebin.vip/view/6a80e309
  1. using System.IO;
  2.  
  3. public static void ErrorLog(string mssg) {
  4.         string FilePath = HttpContext.Current.Server.MapPath("~/log/ErrorLog.txt");
  5.  
  6.         try
  7.         {
  8.                 if (File.Exists(FilePath))
  9.                 {
  10.                         using (StreamWriter tw = File.AppendText(FilePath))
  11.                         {
  12.                                 tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
  13.                         }  //END using
  14.  
  15.                 }  //END if
  16.                 else
  17.                 {
  18.                         TextWriter tw = new StreamWriter(FilePath);
  19.                         tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
  20.                         tw.Flush();
  21.                         tw.Close();
  22.                         tw = null;
  23.                 }  //END else
  24.  
  25.         }  //END Try
  26.         catch (Exception ex)
  27.         { } //END Catch  
  28.  
  29. }  // END ErrorLog
  30. //csharp/5347

Reply to "C c code for writing log to text file"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website