C# Directory CreateDirectory(String)

Description

Directory CreateDirectory(String) Creates all directories and subdirectories in the specified path.

Syntax

Directory.CreateDirectory(String) has the following syntax.


public static DirectoryInfo CreateDirectory(
  string path
)

Parameters

Directory.CreateDirectory(String) has the following parameters.

  • path - The directory path to create.

Returns

Directory.CreateDirectory(String) method returns An object that represents the directory for the specified path.

Example

The following example creates and deletes the specified directory.


/*from   w  w w . j a  v a2s  .  c  om*/
using System;
using System.IO;

class Test 
{
    public static void Main() 
    {
        string path = @"c:\MyDir";
        DirectoryInfo di = Directory.CreateDirectory(path);
        Console.WriteLine(Directory.GetCreationTime(path));

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter