public override void RemoveFolder(Folder folder) { if (!Directory.Exists(folder.GetPath())) { throw new ArgumentException("Folder does not exist (" + folder.GetPath() + ")"); } Document[] removeDocuments = folder.Documents.ToArray(); foreach (Document document in removeDocuments) { RemoveDocument(document); } Folder[] removeFolders = folder.Folders.ToArray(); foreach (Folder subFolder in removeFolders) { RemoveFolder(subFolder); } Directory.Delete(folder.GetPath()); folder.Parent.Folders.Remove(folder); }
/// <summary> /// Rename folder both in file system and internal system. /// </summary> /// <param name="folder"></param> /// <param name="title"></param> public void RenameFolder(Folder folder, string title) { string folderPath = Path.Combine(folder.Parent.GetPath(), Helper.GenerateName(folder.Id, GetAvailableName(title, folder.Id, folder.Parent.GetPath()))); try { Directory.Move(folder.GetPath(), folderPath); } catch (IOException e) { // Should not be accesible Console.WriteLine(e.Message); } folder.Title = title; }