我想知道如何通過C#創建在窗口服務日誌事件文件的新目錄的新目錄創建日誌事件文件在Windows服務在C#
我有以下代碼:
public static void WriteLog(string Message)
{
StreamWriter sw = null;
try
{
sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\DataFile.txt", true);
//sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "C:\\MulpuriServiceLOG\\data.txt", true);
//sw.WriteLine(DateTime.Now.ToString() + ": " + Message);
sw.WriteLine(Message);
sw.Flush();
sw.Close();
}
catch{}
}
希望你應該閱讀這個http://stackoverflow.com/help/how-to-ask –