Add simple Log text file

public static void LogMessage(string Message)

string LogFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, “MyLog.txt”);
//string LogFilePath=Path.Combine(Path.GetTempPath(),”CompassTemplatesLog.txt”);
if (!File.Exists(LogFilePath))
byte[] fileBytes = null;
fileBytes = Encoding.GetEncoding(1252).GetBytes(” Log – \r\n_______________\n”);
using (Stream streamToWrite = File.Create(LogFilePath))
streamToWrite.Write(fileBytes, 0, fileBytes.Length);

using (StreamWriter Writer = File.AppendText(LogFilePath))




   LogMessage(“Start “+DateTime.Now);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s