C# 如何在子文件夹中创建多个文件夹。。。。。。。!

C# 如何在子文件夹中创建多个文件夹。。。。。。。!,c#,winforms,C#,Winforms,如何在子文件夹中创建多个文件夹 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace Progressbar

如何在子文件夹中创建多个文件夹

 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
 using System.IO;
  namespace Progressbar
 {
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    string path = @"A:\DMS\SCOSTADL";
         try       
         {        
             // Determine whether the directory exists.
             if (Directory.Exists(path))             
             {  
                 MessageBox.Show("Paths Exists already!!!!!!!!!");
                 return;
                  }
             // Try to create the directory.
              DirectoryInfo di = Directory.CreateDirectory(path);
             MessageBox.Show("Directory Created Successfully....!");
             } 
        catch (Exception e)         
         {
             Console.WriteLine("The process failed: {0}", e.ToString());
           }
             finally { }
         }
        }
         }

在这个例子中,我可以创建一个文件夹(DMS)和子文件夹(SCOSTADL),我想创建许多子文件夹和子文件夹(SCOSTADL)。请给我一些建议……

CreateDirectory
也可以创建路径中的所有子目录,因此您可以执行
Directory.CreateDirectory(“C:\\abc\\def\\ghi”)

在这个示例应用程序中,我可以创建文件夹和子文件夹,但我想创建一个文件夹和一个子文件夹,其中包含额外的(例如:3个文件夹)文件夹和子文件夹。我认为我们还不了解您想要的文件夹结构。你能写出你想要的吗?每个文件夹都是完整的路径?例如,我创建了一个名为ABC的文件夹和一个子文件夹DEF,但除了这个子文件夹DEF,我还需要更多的文件夹,如GHI、JKLWell,逐个创建它们!您忘记了@sign:
Directory.CreateDirectory(@“C:\abc\def\ghi”)我可以创建文件夹和子文件夹,但我需要几个文件夹和子文件夹。你是什么意思?这将创建3个文件夹:abc、def和ghi,如果它们还不存在。。。