Working with directory(ies) /folder(s)

Don't forget the statement "using System.IO"

// Creating a new directory...
Directory.CreateDirectory("C:\\New Folder");

// Deleting a directory removing all files, subdirectories within it...
Directory.Delete("C:\\New Folder", true);

// Deleting a directory just if it is empty...
Directory.Delete("C:\\New Folder", false);

// Checking whether a directory exist...
if (Directory.Exists("C:\\New Folder"))
{
}

// Moving a directory...
Directory.Move("C:\\New Folder", "D:\\New Folder");

Ebook Download
View all
Learn
View all