【发布时间】:2010-12-01 08:23:44
【问题描述】:
我已使用以下功能将数据写入用户应用程序文件夹
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,代码会更简洁。
标签: c# .net permissions