The following code, running as administrator from local hard drive, using the .Net Framework 2.0, sometimes raises an UnauthorizedAccessException on the second line:
IO.File.SetAttributes(File, IO.FileAttributes.Normal)
IO.File.SetAttributes(File, IO.FileAttributes.Archive)
This happens on a network drive. The faulty files have weird permissions (see end of post), although reading and writing work perfectly.
Worse, even from Explorer, trying to change permissions fail, first asking for admin rights, then failing anyway:


Any ideas? I’m at a complete loss.
Here’s a screenshot of file permissions:
This one works:

This one does not:

I don’t know French much at all( that is the language correct?) but it looks like the first one works because you are a user on the server side (Linux user). When working over network drives, you have to have permissions on the server to change file attributes. Otherwise, it will have to be changed on the server end.
Edit: Some servers also can change file permissions when saved to a network drive depending on the server settings and type of file. These changes may be locked down to only someone with server credentials can modify them and the code then fails with that exception.
Edit2: It’s also possible that it also could be tied down on the server end by indexing and after a few minutes, you will get acccess back.