Q:

C# program to create directory

0

C# program to create directory

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

Note: In above program, we need to remember, when we use "Directory" class, System.IO namespace must be included in the program.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# file handling (File class) solved programs/examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to delete an empty and a non-empty dire... >>
<< C# program to read byte buffer from a file...