How To Create A Folder Using C#

hello this is a simple tutorial not actually a tutorial but yah lets begin this is a console application so you dont need any forms you know that ok so create a new console application project and name it now when the coding part is loaded now you just need to understand the code first of all this is the whole code and this is a picture of the application


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
//Author : Mohamed Shimran
//Blog : http://www.ultimateprogrammingtutorials.blogspot.com
namespace create_folder
{
    class Program
    {
        static void Main(string[] args)
        {
            /////////////////////////////////////////////////////////
            DirectoryInfo newDir = new DirectoryInfo(@"C:/Ultimate");
            if (newDir.Exists)
                Console.WriteLine("The Folder Exist");
            else
                newDir.Create();
            /////////////////////////////////////////////////////////
            Console.Write("Drives");
            foreach (DriveInfo di in DriveInfo.GetDrives())
                Console.WriteLine("{0},({1})", di.Name, di.DriveType);
            Console.ReadKey();
        }

    }
}

so now first of all new directoryinfo(@"C:/Ultimate") in c drive a new folder will be created and the name will be ultimate you can change it and if the folder is created successfully , you will see fixed in the console if the folder already exist in then it will show the folder exist and hope you all understand the code i am not that good in c# so if anything wrong or any feedbacks comment please

Post a Comment

Note: Only a member of this blog may post a comment.