Computer >> Computer tutorials >  >> Programming >> C#

C# Program to create new directories


Use the CreateDirectory method to create a directory.

Let’s say you need to create a directory in D drive. For that, use the CreateDirectory() method as shown below −

Directory.CreateDirectory("D:\\Tutorial");

The following is the code −

Example

using System.IO;
using System;
public class Program {
   public static void Main() {
      Directory.CreateDirectory("D:\\Tutorial");
   }
}