Permissions issue - can't programmatically delete files on the server

R

Rémi

Howdy.
I've got a permissions issue I can't figure out; I've been searching
for info and haven't found anything to help me.

I'm testing an ASP.Net 2.0 application that allows a user to upload
files, and delete them later. The upload works fine; the file gets
saved to the proper directory. The delete does not. Here's the info:

* * *

Access to the path 'F:\My App\Path\SubDir\materials\' is denied.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the
path 'F:\Terra Cognita\Operations\Projects\IRC
E-zine\ProjectFiles\NewWebPublisher\webInterface\ads\materials\' 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 <identity
impersonate="true"/>, 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.

* * *

It's the call to System.IO.File.Delete that causes the exception.

Seems straightforward enough. Except that when I check the folder's
permissions in Windows Explorer (I'm testing on my local machine),
"ASP.NET Machine Account" and "Internet Guest Account" both have full
control on that specific directory. (I started off by giving them
"Delete Subfolders and Files" permissions on that directory, but when
that didn't work...)

Can *anyone* help me figure this out? It's driving me to drink.

Windows 2000, IIS 5.0, Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.42.

Regards,
Remi.
 
D

DKode

that sounds like a ACL permission problem. When the file is uploaded to
that directory, check the permissions on that file and see if they have
the same permissions as the containing folder, if you are in a domain,
you might try setting your asp.net identity to a domain user (just for
testing purposes) and see if you can delete it then, also if you are
uploading the file, ensure that you are disposing the filehandle (if
any) because this could cause a problem as well.
 
S

sChar

Few Tips to debug
1. Try to delete another file from the dir that dir.
2. Check the permissions on file
3. check the ACL permissions on the folder
4. asp.net identity to some domain user rather than anonymous

hth
 
S

sChar

please read 1 as
try to delete another file from that directory that is manually created.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top