关于iis:从ASP.NET Web表单枚举共享文件夹时出错

Error enumerating shared folder from ASP.NET web form

我正在尝试在加载页面时运行一种方法,该方法将搜索网络共享文件夹并对找到的所有.tif文件进行特定操作。 问题是我遇到错误:

1
2
3
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.

我已尝试按照这些说明进行操作,但是无法将指定的帐户添加到共享的权限中。 我究竟做错了什么?

请参阅相关问题:无法从asp.net Web表单访问网络共享


您可能需要冒充具有访问权限的用户:请参阅http://msdn.microsoft.com/en-us/library/xh507fc5%28v=VS.90%29.aspx