开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜