views:

40

answers:

1

Hi, I've got a routine that tries to import files from an import directory, spitting them out to an Error directory if the import fails. The Error directory is shared and users have access permissions to delete files in there, so they can try to fix the problems and then move the files off to the import directory again. I use File.Move to move the files to the Error directory and this is working fine, apart from the permissions - it seems to revert to a default set of permissions, rather than the directory's one, and so the users can't remove the files - how can I reset the permissions on the file to those of their containing directory? I've tried poking around with SetAccessControl and SetAccessRuleProtection but I don't seem to be having any luck?

Cheers

MH

+1  A: 

This Asp.Net Forum link also discusses the same issue and it seems that you need to have administrative privileges. And as suggested in the forum too, this doesn't seem like a good idea. If possible don't delete the files through Asp.Net. Maybe, you can creat a windows service that can access the files and delete whichever are eligible. Just a hint. Giving too much power to Asp.Net is asking for trouble.

Sidharth Panwar
Surely it should just need privileges to change the attributes (but it wouldn't suprise me otherwise). I've taken some of that code and it doesn't seem to work - it (seems to) assigns an extra access right and doesn't throw an error, but when you look at the file there is no change to the rights.
Mad Halfling
Thanks for the answer, looks like this works sporadically or only under certain circumstances, so a bit of caveat emptor for anyone trying to use the code in that link. I'll mark it as the answer to close this off as there doesn't seem to be much of an alternative (plus I've managed to solve this another way)
Mad Halfling
So what approach have you taken to actually solve it?
Sidharth Panwar