I have a line of code checking if a directory exists and then getting the list of files in it.
System.IO.Directory.Exists(@\"\\\\Server\\Folder\\\");
I was was getting this error with code a UNC that looked like this:
@"\Server01\c$\Data\SubFolder"
I made an explicit share and got rid of the c$
and made it look like this:
@"\Server01\TheData\SubFolder"
and it started to work.
I am not 100% sure that is what fixed the permissions problem, but it started to work immediately after making that change.