2011-04-14 63 views
0

我試圖運行一個加載頁面的方法,該頁面將搜索網絡共享文件夾並對所有找到的.tif文件執行特定操作。問題是,我發現了一個錯誤:枚舉ASP.NET web窗體中的共享文件夾時出錯

DirectoryInfo dir = new DirectoryInfo(directory); 

FileInfo[] tifs = dir.GetFiles("*.tif", SearchOption.AllDirectories); //Throws error. 

Exception Details: System.UnauthorizedAccessException: Access to the path '\server\sharename\folder\subfolder' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

我試圖按照這些指示,但我沒能到指定的帳戶添加到共享的權限。我究竟做錯了什麼?

查看相關的問題:Trouble accessing network share from asp.net web form

回答