如何在插入文件之前检查目录是否存在
问题描述:
我有一个类似于C:\application\photo\gallery\sketches
的路径。如何在插入文件之前检查目录是否存在
现在我需要检查整个路径是否退出或没有将文件插入此位置之前。
答
Directory.Exists Method是你在找什么:
using System.IO;
//...
if(Directory.Exists(path))
{
// your stuff here
}