如何在插入文件之前检查目录是否存在

hap*_*ile 1 asp.net

我有一条路C:\application\photo\gallery\sketches.

现在我需要在将文件插入此位置之前检查整个路径是否退出.

Joh*_*dol 7

Directory.Exists方法是您正在寻找的:

using System.IO;

//...

if(Directory.Exists(path)) 
{
    // your stuff here
}
Run Code Online (Sandbox Code Playgroud)