I have a file share on a remote PC, read only, guest access is on. I'm trying to read a file from that share via its UNC path, from a desktop app, using the code like this: var bytes = File.ReadAllBytes(@"\\someservser\someshare\somefile.txt");
, but getting the following exception:
System.IO.IOException
HResult=0x80070569
Message=Logon failure: the user has not been granted the requested logon type at this computer.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
This exception was originally thrown at this call stack:
System.IO.__Error.WinIOError(int, string) in __error.cs
System.IO.FileStream.Init(string, System.IO.FileMode, System.IO.FileAccess, int, bool, System.IO.FileShare, int, System.IO.FileOptions, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES, string, bool, bool, bool) in filestream.cs
System.IO.FileStream.FileStream(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, int, System.IO.FileOptions, string, bool, bool, bool) in filestream.cs
System.IO.File.InternalReadAllBytes(string, bool) in file.cs
I can open this file from Windows UI without any problem (same user as used to run the failing app).
Any ideas?