I am trying to delete a directory and all its contents like this:
private static void CleanOrCreateDirectory(string directory)
{
if (Directory.Exists(directory)) Directory.Delete(directory, true);
Directory.CreateDirectory(directory);
}
which should be the standard way, suggested in various answers to related questions on SO. However, it doesn't work. I get:
System.IO.IOException : The directory is not empty.
Well, of course it is not empty, that is the whole point! What am I doing wrong?