How to check whether a directory exists before inserting a file
I have a path like C:\application\photo\gallery\sketches
.
Now I need to check whether 开发者_JAVA技巧this entire path exits or not before inserting a file into this location.
Directory.Exists Method is what you're looking for:
using System.IO;
//...
if(Directory.Exists(path))
{
// your stuff here
}
Take a look at Directory.Exists.
精彩评论