using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Configuration; namespace GTSS { public class Logger { public string logFile = ""; public string dataLogFile = ""; public Logger() { System.Configuration.AppSettingsReader reader1 = new System.Configuration.AppSettingsReader(); logFile = (string)reader1.GetValue("LogFile", logFile.GetType()); dataLogFile = (string)reader1.GetValue("DataLogFile", dataLogFile.GetType()); } public void AddLogEntry(string entry) { StreamWriter outFile = new StreamWriter(logFile, true); //StreamWriter outfile = new StreamWriter(logFile); //s.Append(quotes + "LVTS" + quotes + "," + quotes + dtTrades.Rows.Count.ToString() + quotes + "," + quotes + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + quotes + "," + quotes + DateTime.Now.ToString("MM/dd/yyyy") + quotes); outFile.WriteLine(entry); outFile.Close(); } public void archive_log() { if (File.Exists(logFile.ToString())) { File.Copy(logFile, logFile.Substring(0, logFile.Length - 4) + "_" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ".txt"); File.Delete(logFile.ToString()); } } public void AddDataLogEntry(string entry) { StreamWriter outFile = new StreamWriter(dataLogFile, true); //StreamWriter outfile = new StreamWriter(logFile); //s.Append(quotes + "LVTS" + quotes + "," + quotes + dtTrades.Rows.Count.ToString() + quotes + "," + quotes + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + quotes + "," + quotes + DateTime.Now.ToString("MM/dd/yyyy") + quotes); outFile.WriteLine(entry); outFile.Close(); } public void delete_data_log() { if (File.Exists(dataLogFile.ToString())) { File.Delete(dataLogFile.ToString()); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)