0

サブフォルダに多くのフォルダを作成する方法

 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)と一緒に多くのサブフォルダを作成したいと思います。提案をお願いします......

4

1 に答える 1

3

CreateDirectoryパス内にもすべてのサブディレクトリを作成するので、次のことができますDirectory.CreateDirectory("C:\\abc\\def\\ghi");

于 2012-04-14T05:06:12.590 に答える