开发者

How can I determine if a subdirectory exists in C#?

开发者 https://www.devze.com 2023-02-01 07:33 出处:网络
In C#, how can one determine if a subdirectory exists? Is this开发者_如何学编程 neccesary when calling CreateSubDirectory?if(System.IO.Directory.GetDirectories(path).Length>0)

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

Is this开发者_如何学编程 neccesary when calling CreateSubDirectory?


if(System.IO.Directory.GetDirectories(path).Length>0)
{
//if this condition is true-->> Directory has sub-sirectories

} 


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


Do you need this?

if(Directory.Exists(path)) 
{
     // This path is a directory
     ProcessDirectory(path);
}


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


System.IO.Directory.Exists

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号