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);
}

Solution 4

Use System.IO.Directory.Exists. MSDN is your friend :)

Solution 5

System.IO.Directory.Exists

Share:
14,059

Related videos on Youtube

user496949
Author by

user496949

Updated on June 04, 2022

Comments

  • user496949
    user496949 almost 2 years

    In C#, how can one determine if a subdirectory exists?

    Is this neccesary when calling CreateSubDirectory?

Related