While investigating an issue I found this in my log file:
2016-10-26 09:36:41,141 - Scan - ERROR - MyApp.Business.SyncService - Error analyzing local changes
System.UnauthorizedAccessException: Empty path
à Pri.LongPath.Common.ThrowIOError(Int32 errorCode, String maybeFullPath)
à Pri.LongPath.FileSystemInfo.Refresh()
à Pri.LongPath.DirectoryInfo.get_Exists()
...
I first tried to understand how I could possibly end-up with a DirectoryInfo with an empty path, since the path is validated at construction time, but looking at the code, I think the message is incorrect and misleading. The message "Empty path" comes from here:
case NativeMethods.ERROR_ACCESS_DENIED:
if (str.Length == 0)
throw new UnauthorizedAccessException("Empty path");
else
throw new UnauthorizedAccessException(String.Format("Access denied accessing {0}", str));
I agree, this doesn't seem right. I can't think of any reason why that should be empty (otherwise there would be a unit test for it :) ), probably just a bug. Thanks for detailing it and submitting a PR.
While investigating an issue I found this in my log file:
I first tried to understand how I could possibly end-up with a
DirectoryInfo
with an empty path, since the path is validated at construction time, but looking at the code, I think the message is incorrect and misleading. The message "Empty path" comes from here:because the
maybeFullPath
parameter is empty.Common.ThrowIOError
is called from here:Is there any reason not to pass
FullPath
instead ofstring.Empty
?