Home Programs Create a Directory in C#

Create a Directory in C#

In this example we show how to create a new directory in C#

Example

The new Directory is created on the J drive directory using the CreateDirectory() function.

You may need to change the directory name you want to create and the name of the directory

using System;
using System.IO;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Directory.CreateDirectory("J:\\MyDirectory");
            Console.WriteLine("MyDirectory is Created in the J Drive");
            Console.ReadLine();
        }
    }
}

You should see a message like this

MyDirectory is Created in the J Drive

You may also like