2011-04-14 62 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

回答