检查的文件夹目录中存在并使用C#创建它们
问题描述:
我如何检查是否目录 C:/
包含一个文件夹命名为 MP_Upload
,如果它不存在自动创建文件夹?
How can I check if directory C:/
contains a folder named MP_Upload
, and if it does not exist, create the folder automatically?
我在使用Visual &工作室NBSP; 2005年C#
I am using Visual Studio 2005 C#.
答
这应该有所帮助:
using System.IO;
...
string path = @"C:\MP_Upload";
if(!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}