Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a file directory path as \\x\y\z(directory exists) .

when I pass the above path to directory.exists() methods it returns true which

is fine

now I pass path as directory.exists("\\x\y\\z"). it should return false but this method returns true even though the path does not exists.

any suggestions ?

TIA
Posted
Updated 6-Sep-15 20:18pm
v2
Comments
Maciej Los 7-Sep-15 2:21am    
Finally, which string do you pass as a parameter to Directory.Exists() method: \\x\y\\z or \\x\y\z
Sriharsha Denni 7-Sep-15 2:39am    
im passing \\x\y\\z(invalid path) as parameter . but method is returning true
Maciej Los 7-Sep-15 2:51am    
It can't be true! Please, see my answer.

1 solution

As documentation[^] says:

MSDN wrote:
If you do not have at a minimum read-only permission to the directory, the Exists method will return false.

The Exists method returns false if any error occurs while trying to determine if the specified file exists. This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, a failing or missing disk, or if the caller does not have permission to read the file.


So, debug your program to find out where the bug is.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900