...运行时在D盘自动生成一个文件夹,并且包含四个子文件夹的代码...
发布网友
发布时间:2024-10-19 09:03
我来回答
共1个回答
热心网友
时间:2024-11-21 18:51
using System.IO;
string parentFolder = "文件夹名";
string[] folderArray = new string[]{"子文件夹1","子文件夹2","子文件夹3","子文件夹4"}
string parentFolderPath = string.Format{@"D:\{0}",parentFolder }
if (!Directory.Exists(parentFolderPath))
{
//没有自动生成文件夹
Directory.CreateDirectory(folderPath);
}
foreach(string folder in folderArray )
{
string folderPath = string.Format{@"{0}\{1}", parentFolderPath ,folder }
if(!Directory.Exists(folderPath)))
{
Directory.CreateDirectory(folderPath );
}
}
//是否四个子文件夹
DirectoryInfo theFolder = new DirectoryInfo(parentFolderPath );
if(theFolder.GetDirectories().Length == 4)
{
return true;
}
别说不懂,别吝啬分。