public static void LogInfo(string Message)
{
try
{
bool EnableLog = true;
if (EnableLog)
{
string LogFile = "D:\\Logs\\revenu_" +DateTime.Now.Day.ToString("00") + DateTime.Now.Month.ToString("00") +DateTime.Now.Year;
StreamWriter sw;
if (!string.IsNullOrEmpty(LogFile))
LogFile.Replace("revenu__Logs","revenu_" + DateTime.Today.Date.ToString().Substring(0, 10));
if (!File.Exists(LogFile))
{
sw = File.CreateText(LogFile);
sw.WriteLine(string.Format("Log File Created: {0}",DateTime.Now.ToString()));
sw.Close();
}
sw = File.AppendText(LogFile);
sw.WriteLine(string.Format("{0}: {1}",DateTime.Now.ToString(), Message));
sw.Flush();
sw.Close();
}
}
catch (Exception ex)
{
throw ex;
}
}
No comments:
Post a Comment