How to create many folders in a sub-folder
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 { }
}
}
}
Here in this example i am able create a folder(DMS) and sub-folder(SCOSTADL) and i want to create many sub-folders along with Sub-folder(SCOSTADL).please give me suggestions……
CreateDirectorycreates all sub-directories in the path as well, so you can doDirectory.CreateDirectory("C:\\abc\\def\\ghi");.