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:
C#
if(Directory.Exists("a.b"))
{
// Folder
}


where a.b is my Folder name, Even its a directory its throwing an exception
Posted
Updated 8-Apr-13 7:44am
v2
Comments
Sergey Alexandrovich Kryukov 7-Apr-13 22:56pm    
Very bad. You don't see a difference between directory and a directory on the server part of FTP server.
More importantly, you should always understand the path names — relative to what?
—SA

1 solution

You must have done something wrong, as hte code is exactly as specifyed in the documentation:
http://msdn.microsoft.com/en-us/library/system.io.directory.exists.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2[^]

So How do you generate the path string?
 
Share this answer
 
Comments
Friendsaa 7-Apr-13 16:25pm    
My directory name is "A.B"
And its path is FTP link
Kenneth Haugland 7-Apr-13 16:29pm    
You might want to try a different approch then:
http://stackoverflow.com/questions/2769137/c-sharp-how-to-check-if-an-ftp-directory-exists

Directory.Exists is meant for folders you are allowed to accsess.
Sergey Alexandrovich Kryukov 7-Apr-13 22:54pm    
My 5. At least one of the answers in this discussion is correct.
—SA

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