private static void DeleteFileSystemInfo(FileSystemInfo fileSystemInfo)
{
var directoryInfo = fileSystemInfo as DirectoryInfo;
if (directoryInfo != null)
{
foreach (var childInfo in directoryInfo.GetFileSystemInfos())
{
DeleteFileSystemInfo(childInfo);
}
}
fileSystemInfo.Attributes = FileAttributes.Normal; // thumbnails can be intentionally readonly (when they are created by hand)
fileSystemInfo.Delete();
}