public bool DeleteDirectory(string target) { if (!Files.ContainsKey(target)) { return(false); } IDictionary <string, FileDescriptor> filesToRemove = new Dictionary <string, FileDescriptor>(); foreach (var file in Files) { if ((Files[file.Key].Path.Substring(0, Math.Min(Files[file.Key].Path.Length, target.Length))) == target) { foreach (var sector in Files[file.Key].Sectors) { Sectors.Remove(sector.Id); } filesToRemove.Add(file.Key, file.Value); } } foreach (var file in filesToRemove) { Files.Remove(file.Key); } return(true); }
public bool Delete(string target) { if (!Files.ContainsKey(target)) { return(false); } var file = Files[target]; foreach (var sector in file.Sectors) { Sectors.Remove(sector.Id); } Files.Remove(target); return(true); }