How can I determine if a subdirectory exists in C#?
14,059
Solution 1
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
Solution 2
if(System.IO.Directory.GetDirectories(path).Length>0)
{
//if this condition is true-->> Directory has sub-sirectories
}
Solution 3
Do you need this?
if(Directory.Exists(path))
{
// This path is a directory
ProcessDirectory(path);
}
Related videos on Youtube
Author by
user496949
Updated on June 04, 2022Comments
-
user496949 almost 2 years
In C#, how can one determine if a subdirectory exists?
Is this neccesary when calling
CreateSubDirectory
?