Search This Blog

Wednesday, February 11, 2015

Create new directory with DirectoryInfo C#

C# > Files > DirectoryInfo Class

Use this class for create, move and enumerating directories and subdirectories. 

Example 

Create new directory

DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\Yourdir");
try
{
if (!directoryInfo.Exists)
       {
              directoryInfo.Create();
       }
}
catch (Exception ex)
{
MessageBox.Show("DirectoryInfo error: {0}", ex.ToString());
}
finally { }