开发者

How to check whether a directory exists before inserting a file

开发者 https://www.devze.com 2022-12-10 15:03 出处:网络
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 Meth

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.

0

精彩评论

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

关注公众号