Wednesday, June 19, 2019
c# utility to log in a text file
using System.IO;
//Loggin
public static string LogFilePath;
public static bool DebugMode;
LogFilePath = Properties.Settings.Default.LogFilePath;
DebugMode = Properties.Settings.Default.DebugMode;
public static void LogWrite(string logText)
{
if (GlobalVars.DebugMode)
{
// check to see if the directory exists
FileInfo logFile = new FileInfo(GlobalVars.LogFilePath);
if (!logFile.Directory.Exists)
{
logFile.Directory.Create();
}
logText = Environment.NewLine + DateTime.Now + " - " + logText;
File.AppendAllText(GlobalVars.LogFilePath, logText);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment