Rank: Member Groups: Member
Joined: 9/2/2008 Posts: 0
|
using System.IO; public string GetTempPath() { string path = System.Environment.GetEnvironmentVariable("TEMP"); if (!path.EndsWith("\\")) path += "\\"; return path; }
public void LogMessageToFile(string msg) { System.IO.StreamWriter sw = System.IO.File.AppendText( GetTempPath() + "My Log File.txt"); try { string logLine = System.String.Format( "{0:G}: {1}.", System.DateTime.Now, msg); sw.WriteLine(logLine); } finally { sw.Close(); } }
|