【发布时间】:2011-09-09 08:19:15
【问题描述】:
无法创建类的实例 测试类。错误: System.UnauthorizedAccessException: 访问路径 'C:\Documents 和 设置\管理员\我的 文档\Visual Studio 2010\Projects\TestProject' 被拒绝。
System.IO.__Error.WinIOError(Int32 错误代码,字符串可能是FullPath) System.IO.FileStream.Init(字符串路径, FileMode 模式,FileAccess 访问, Int32 权限,布尔用户权限, FileShare 共享,Int32 bufferSize, 文件选项选项, SECURITY_ATTRIBUTES secAttrs,字符串 msgPath,布尔值 bFromProxy,布尔值 使用长路径) System.IO.FileStream..ctor(字符串 路径、FileMode 模式、FileAccess 访问、文件共享共享、Int32 bufferSize,FileOptions 选项, 字符串 msgPath,布尔 bFromProxy) System.IO.FileStream..ctor(字符串 路径,文件模式模式) C:\Documents 中的 KM_Automation.KM_Library.GetAutoConfig() 和 设置\管理员\我的 文档\Visual Studio 2010\Projects\TestProject\Test_Library.cs: 第 40 行 KM_Automation.KM_Functional_Trans_General..ctor() 在 C:\Documents 和 设置\管理员\我的 文档\Visual Studio 2010\Projects\TestProject\TestClass.cs: 第 33 行
Test_Library.cs:
public string[] GetAutoConfig()
{
FileStream fs = new FileStream(sConfigFile, FileMode.Open); // line 40
StreamReader sr = new StreamReader(fs);
string line = "";
string[] arrline = new string[2];
}
TestClass.cs:
arrConfig = KMLib.GetAutoConfig(); // line 33
为什么会出现此错误?我确保该文件夹已共享给所有人,并删除了只读。
【问题讨论】:
标签: c# .net exception-handling selenium