C# delete a folder and all files and folders within that folder

dir.Delete(true); // true => recursive delete

Read the Manual:

Directory.Delete Method (String, Boolean)

Directory.Delete(folderPath, true);

Try:

System.IO.Directory.Delete(path,true)

This will recursively delete all files and folders underneath "path" assuming you have the permissions to do so.