My program requires access to a certain UNC path, but the path is cross-domain, so depending on the machine the program is being run on, it may or may not have default crede
I have never done this, but what you may be asking to do is check the Access Control List (ACL) in NTFS.
I did a web search for c# and "Access Control List" and got a couple of hits that may be of interest to you. This may be cleaner, but it may not be easier that what you are already doing.
Check these articles:
I've used code like this:
new FileIOPermission(FileIOPermissionAccess.Read, path).Demand();
which is supposed to throw a SecurityException
if you don't have the desired access, but for paths on network drives or UNC paths, the FileIOPermission.Demand()
method appears to be a no-op.