Delete the created directory/folder in C#

Saratvaddilli
Posted by Saratvaddilli under C# category on | Points: 40 | Views : 854
using System;

using System.IO;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

string directoryName = Directory.GetCurrentDirectory() + @"\NewDir";



//Creates a new directory named "NewDir" within the current directory

Directory.CreateDirectory(directoryName);

Console.WriteLine("Created: {0}", directoryName);

//Deletes the directory named "NewDir" which is just created above
Directory.Delete(directoryName); Console.WriteLine("Deleted: {0}", directoryName);
}
}
}

Comments or Responses

Login to post response