Possible Duplicate:
Recursive delete of files and directories in C#
I am trying to delete all files and folders in a root folder but my program keeps crashing because some files are over the 256 or something limit.
What I need to do is go to the last folder delete all the files and then delete that folder and work my way upto the root folder and then delete that.
I'm stuck on how to do this please can someone help with a simple way to do this?
many thanks for any help
I'm using C#, the code is:
private void RemoveDirectory(DirectoryInfo directory)
{
RemoveReadOnly(directory);
directory.Delete(true);
bool directoryExists = true;
while (directoryExists)
directoryExists = Directory.Exists(directory.FullName);
SendProgressMessage(string.Format("Removed {0}", directory.FullName));
}