我使用了follwing函数将数据写入用户应用程序文件夹
private void WriteToLog(string source,string method,string msg) { string LogFile =Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\test"; LogFile = LogFile + "\\Log.txt"; StreamWriter sw = new StreamWriter(LogFile,true ); string str = DateTime.Now.ToString() + "source=" + source + "\t Method=" + method + "\t" + msg; sw.WriteLine(str); sw.Flush(); sw.Close(); }@H_301_3@