private void CleanUpFolder(IFolder folder, IErrorsAndInfos errorsAndInfos) { if (!folder.Exists()) { return; } if (!FolderDeleter.CanDeleteFolder(folder)) { errorsAndInfos.Errors.Add($"Folder deleter refuses to delete {folder.FullName}"); return; } try { foreach (var file in Directory.GetFiles(folder.FullName, "*.*", SearchOption.AllDirectories)) { File.SetAttributes(file, FileAttributes.Normal); } FolderDeleter.DeleteFolder(folder); } catch (Exception e) { errorsAndInfos.Errors.Add($"Could not delete {folder.FullName}"); errorsAndInfos.Errors.Add(e.Message); } }
public void WhenIAskTheFolderDeleteIfIAmAllowedToDeleteTheFolder() { CanDeleteFolder = Sut.CanDeleteFolder(Folder); }