Reputation: 86085
In C#, how can one determine if a subdirectory exists?
Is this neccesary when calling CreateSubDirectory
?
Upvotes: 7
Views: 17095
Reputation: 2388
if(System.IO.Directory.GetDirectories(path).Length>0)
{
//if this condition is true-->> Directory has sub-sirectories
}
Upvotes: 9
Reputation: 22681
If the subdirectory already exists, this method does nothing.
http://msdn.microsoft.com/en-us/library/h8dtw1d6.aspx
Use Directory.Exists
to check if it exists
http://msdn.microsoft.com/en-us/library/system.io.directory.exists.aspx
Upvotes: 7
Reputation: 50712
Do you need this?
if(Directory.Exists(path))
{
// This path is a directory
ProcessDirectory(path);
}
Upvotes: 3