C# program to create directory

Syntax

DirectoryInfo Directory.CreateDirectory(string path);

Program

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Directory creating:");
            
            Directory.CreateDirectory("D:/India");
            Console.WriteLine("D:/India");

            Directory.CreateDirectory("D:/India/NCR");
            Console.WriteLine("D:/India/NCR");

            Directory.CreateDirectory("D:/India/NCR/DELHI");
            Console.WriteLine("D:/India/NCR/DELHI");

            Directory.CreateDirectory("D:/India/NCR/NOIDA");
            Console.WriteLine("D:/India/NCR/NOIDA");

            Directory.CreateDirectory("D:/India/NCR/GURUGRAM");
            Console.WriteLine("D:/India/NCR/GURUGRAM");
        }
    }
}

Output

Directory creating:
D:/India
D:/India/NCR
D:/India/NCR/DELHI
D:/India/NCR/NOIDA
D:/India/NCR/GURUGRAM

Leave a Comment

error: Alert: Content is protected!!