I have a Windows Service created in .NET 4.
I need to access a file from antoher server and I get an exception:
"UnauthorizedAccessException was caught" - "Access to the path '(path)' is denied."
If I make a new Windows Forms application which accessed that file, it works. The Windows Service runs as Local System.
Apparently your machine account does not have permissions to access remote file share. You have to grant rights to the machine account
<DOMAIN>\<machine_name>$on both file share level as well as file system level. For share permissions usefsmgmt.msc, for file system you can do it usingcaclscommand.Alternative solution is to impersonate a valid user account that already has permission to this directory.