Directory.Exists - UNC path with access denied c #
I am writing code to access directories and index found files. A user can enter a UNC path and impersonate another user to access this directory. I am using Directory.Exists to check if the path they entered is valid before trying to access it.
This works great for local paths, but when I try to access a UNC path that I know I don't have, Directory.Exists returns true.
My understanding is that Directory.Exists does not check if a particular path can only "access" that it exists or not.
What else can I use to check if a directory exists and I have access to it?
I don't know any of the filenames inside the directory at the moment.
Thank!
+2
source to share
3 answers