C#创建文件夹与父文件夹

 

// 递归判断与创建文件夹与父文件夹

 1 public void CreateDirectory(string path)
 2 {
 3     DirectoryInfo info = new DirectoryInfo(path);
 4     if (!info.Exists)
 5     {
 6         if (info.Parent.Exists == false)
 7         {
 8             CreateDirectory(info.Parent.FullName);
 9         }
10         info.Create();
11     }
12 }

 

posted @ 2021-01-15 15:38  ArthurHong7  阅读(203)  评论(0编辑  收藏  举报