我已經使用了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();
}
上面的代碼在管理員帳戶完美的工作,但在有限的用戶未能佔
如果您使用Path.Combine,代碼會更清潔一些。 – epotter 2012-11-07 20:51:28