文件夹
创建文件夹
//如果文件夹路径不存在则创建文件夹
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
递归创建文件夹

public void createdir(string fullpath)
{
if (!File.Exists(fullpath))
{
string dirpath = fullpath.Substring(0, fullpath.LastIndexOf('\\'));
//string[] pathes = dirpath.Split('\\');
string[] pathes = fullpath.Split('\\');
if (pathes.Length > 1)
{
string path = pathes[0];
for (int i = 1; i < pathes.Length; i++)
{
path += "\\" + pathes[i];
//如果文件夹路径不存在则创建文件夹
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
}
}
}
}
View Code