Is there any alternative for System.IO.DirectoryInfo.Exists

The System.IO.DirectoryInfo.Exists always return false if i am giving a UNC like this \192.168.0.33Others (F).

and it occurs only when I run from the installed application, otherwise it will return true if the path is true.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

To access UNC file, you need to first connect to the network location by providing credentials and opening the connection to the network share, after that you can run DirectoryInfo.Exists

Look into P/Invoke to WNetAddConnection2 / NetUseAdd and pass the username/password- then you should be able to access the file / folder info.

Edit:

Try this class I made to connect to UNC paths:
http://www.mediafire.com/?77ae4ratoqa7s4b

Method 2

It should work. My guess is that the account that your code is running under doesn’t have access to the UNC path.

Method 3

See How Can I Determine if a Folder Exists on a Computer?

Method 4

Try System.IO.Directory.Exists().


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x