private bool AttemptToReplaceMissingImage(string missingFile, string pathToFolderOfReplacementImages, IProgress progress)
{
try
{
foreach (var imageFilePath in Directory.GetFiles(pathToFolderOfReplacementImages, missingFile))
{
RobustFile.Copy(imageFilePath, Path.Combine(_folderPath, missingFile));
progress.WriteMessage(string.Format("Replaced image {0} from a copy in {1}", missingFile,
pathToFolderOfReplacementImages));
return true;
}
foreach (var dir in Directory.GetDirectories(pathToFolderOfReplacementImages))
{
// doesn't really matter
// if (dir == _folderPath)
// {
// progress.WriteMessage("Skipping the directory of this book");
// }
if (AttemptToReplaceMissingImage(missingFile, dir, progress))
return true;
}
return false;
}
catch (Exception error)
{
progress.WriteException(error);
return false;
}
}