private static void DeleteExistingDirectory(string destinationFolder)
{
foreach (var dir in Directory.GetDirectories(destinationFolder))
{
DeleteExistingDirectory(dir);
}
//By Bloom convention, thumbnails that were created by hand are marked "read only" so that the
//thumbnail generator never overwrites them. However now that we're trying to clear out this
//folder, we need to remove that readonly flag so we can delete it.
foreach (var f in Directory.GetFiles(destinationFolder))
{
var attributes = RobustFile.GetAttributes(f);
if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
RobustFile.SetAttributes(f, attributes & ~FileAttributes.ReadOnly);
}
}
SIL.IO.RobustIO.DeleteDirectory(destinationFolder, true);
}