之前写入文件:文件访问问题
using (StreamWriter outfile = new StreamWriter(filePath, false, System.Text.Encoding.UTF8))
{
outfile.Write(content);
}
我检查文件写入accsses使用此:
public bool CheckIfAccessToFileIsGranted(string filePath)
{
try
{
new FileIOPermission(FileIOPermissionAccess.Write, filePath).Demand();
return true;
}
catch (SecurityException)
{
return false;
}
}
尽管有上述功能的事实给予我的评价(返回true) ,我在打开流时遇到了UnauthorizedAccessException。为什么?
问候
+1只为最后一句话... – 2010-11-19 18:19:29