private void DeleteOrMoveTheFiles(SyncPostProcContent content) { foreach (var file in content.DeletedFiles) { if (addedFiles.Contains(file.Path, StringComparer.InvariantCultureIgnoreCase)) { MoveFile(file); } else { DeleteFile(file); } } }
private void ChangeAttributesOnFolders(SyncPostProcContent data) { foreach (var dir in data.ChangedDirectories) { var dirInfo = new DirectoryInfo(dir.Path); FileAttributes attributes; if (FileAttributes.TryParse(dir.Attributes, true, out attributes)) { dirInfo.Attributes = attributes; } else { throw new InvalidAttributesException(string.Format("Unable to parse attributes [{0}].", dir.Attributes)); } } }
private void DeleteTheFiles(SyncPostProcContent content) { foreach (var file in content.DeletedFiles) { var fileInfo = new FileInfo(file.Path) { Attributes = FileAttributes.Normal }; try { fileInfo.Delete(); SyncResult.DeletedFiles.Add(file.Path); SyncResult.Log.Add("Deleted: " + file.Path); } catch (Exception e) { var msg = string.Format("Error: Could not delete the file '{0}'. Error: {1}", file.Path, e.Message); SyncResult.Errors.Add(msg); } } }
private void DeleteTheDirectories(SyncPostProcContent content) { foreach (var dir in content.DeletedDirectories.OrderByDescending(x => x.RelativePath)) { var dirInfo = new DirectoryInfo(dir.Path) { Attributes = FileAttributes.Normal }; try { dirInfo.Delete(); SyncResult.DeletedDirectories.Add(dir.Path); SyncResult.Log.Add("Deleted: " + dir.Path); } catch (Exception e) { var msg = string.Format("Error: Could not delete the directory '{0}'. Error: {1}", dir.Path, e.Message); SyncResult.Errors.Add(msg); } } }
private void DeleteOrMoveFiles(SyncPostProcContent content) { DeleteOrMoveTheFiles(content); DeleteTheDirectories(content); }