It is sometime difficulte to delete folder or directory in your machine with applications.
This is one of the easiest way. to resset the files permissions before deleting them.
public static bool DeleteFolder(string dir)
{
bool result = false;
string[] files = Directory.GetFiles(dir);
string[] directory = Directory.GetDirectories(dir);
foreach (string file in files)
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
foreach (string st in directory)
{
DeleteDirectory(st);
Directory.Delete(dir, false );
return result;
} }}