我已经使用了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();
}
上面的代码可以正常使用管理员帐户,但在有限的用户帐户失败