Hi, I'm using MVC ASP.NET 3.5 and I'm trying to delete a folder with all files within using standard .NET method that I've always used in .NET 2.0.
I found this but the first answer doesn't seem to work.
I've tried this one
try
{
Directory.Delete(path, true);
}
catch (IOException)
{
Thread.Sleep(0);
Directory.Delete(path, true);
}
and works, but I can't understand why.
Any suggestions?
Edit: I've got permissions, because all files and sub-folders were deleted. But I've got and Exception "Directory is non-empty" with path. If I use the code provided, works without any exceptions.