I have a server written in C# that makes use of impersonation.
I would like to know how I can change the security attributes of a file so that any user can delete it
Instead of allowing everyone delete the file, why not add entries for just the people who need to delete the file. Based on your post, that would likely be your user account and the originating process. Allowing literally everyone to delete the file opens yourself up to security problems down the road.
public static void AllowIdentityToDelete(FileInfo file, string identity)
{
var rule = new FileSystemAccessRule(
identity,
FileSystemRights.Delete | FileSystemRights.DeleteSubdirectoriesAndFiles,
AccessControlType.Allow);
var acls = file.GetAccessControl();
acls.AddAccessRule(rule);
file.SetAccessControl(acls);
}
You'll need to pass in the proper Identity for the user in question.