Unable to create instance of class TestClass. Error: System.UnauthorizedAccessException: Access to the path 'C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\TestProject' is denied.無法創建類的實例
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) System.IO.FileStream..ctor(String path, FileMode mode) KM_Automation.KM_Library.GetAutoConfig() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\TestProject\Test_Library.cs: line 40 KM_Automation.KM_Functional_Trans_General..ctor() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\TestProject\TestClass.cs: line 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
爲什麼會出現這個錯誤?我確定該文件夾是共享給所有人的,並刪除了只讀。
非常感謝你:) – Maya 2011-06-06 15:02:13