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

问题描述:

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

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)。请给我建议......

+0

在这个示例应用程序,我能够创建文件夹和子文件夹,但我想创建一个文件夹和子文件夹与额外的(例如:3folders)文件夹以及子文件夹 – user1312412 2012-04-14 05:14:41

+0

我不认为我们理解什么你想要的文件夹结构。你能写出你想要的,每个文件夹为* full *路径吗? – 2012-04-14 05:21:45

+0

例如我创建了一个名称为ABC的文件夹和一个子文件夹DEF,但是与此子文件夹DEF一起,我需要更多的文件夹,例如GHI,JKL – user1312412 2012-04-14 05:25:02

CreateDirectory也创建路径中的所有子目录,所以你可以做Directory.CreateDirectory("C:\\abc\\def\\ghi");

+0

你忘了@ sign:'Directory.CreateDirectory(@“C:\ abc \ def \ ghi”);' – 2012-04-14 05:16:40

+0

是的,我试图逃避我的反斜杠,但它拒绝? :) – Torious 2012-04-14 05:19:46

+0

我能够创建一个文件夹和子文件夹,但我需要几个文件夹以及子文件夹 – user1312412 2012-04-14 05:20:10