File.WriteAllText throws UnauthorizedAccessException

.net, file-access, windows

Solution

According to MSDN, `UnauthorizedAccessException` can also be caused by:

path specified a file that is read-only.

-or- 

This operation is not supported on the current platform.

-or- 

path specified a directory.

Is it possible one of these conditions is the cause of your problem?

Problem

Doing `File.WriteAllText` to a remote path throws `UnauthorizedAccessException`. When I open the file in notepad I can edit it without a problem. The process that's trying to modify the file is running as my own user account, so it should be able to access it.

Original source