0

I'm trying to run a method on the loading of a page which will search through a network shared folder and do a particular operation on all .tif files found. Problem is I'm getting an error:

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.

I've tried following these instructions, but I'm not able to add the specified account to the share's permissions. What am I doing wrong?

See Related Question: Trouble accessing network share from asp.net web form

1 Answer 1

1

You probably need to impersonate a user that does have access: see http://msdn.microsoft.com/en-us/library/xh507fc5%28v=VS.90%29.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

Using Web.Config impersonation didn't work for me, but this did: platinumdogs.wordpress.com/2008/10/30/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.