Search code examples
asp.netfileimpersonation

Cannot delete file in share using impersonation on ASP.NET site


We have a web farm and are writing temp files for reports. We set up a file share and are using impersonation to write the temporary report files to that share. We gave the account doing the impersonation full control to the share and the folder itself.

The files are writing correctly but are not being deleted. Is there something we're missing with this setup?


Solution

  • Not sure what method you are using to write the files. The following is what I ended up doing in order to read files. Maybe you could try this method for deleting them as well.

    How can I temporarily impersonate a user to open a file?