/// <summary> /// Deletes a directory and de-indexes all its contents. /// </summary> /// <param name="provider">The provider.</param> /// <param name="directory">The directory to delete.</param> public static bool DeleteDirectory(IFilesStorageProviderV40 provider, string directory) { if (provider == null) { throw new ArgumentNullException("provider"); } if (directory == null) { throw new ArgumentNullException("directory"); } if (directory.Length == 0 || directory == "/") { throw new ArgumentException("Cannot delete the root directory", "directory"); } directory = NormalizeFullPath(directory); // This must be done BEFORE deleting the directory, otherwise there wouldn't be a way to list contents DeletePermissions(provider, directory); DeindexDirectory(provider, directory); // Delete Directory bool done = provider.DeleteDirectory(directory); if (!done) { return(false); } Host.Instance.OnDirectoryActivity(provider.GetType().FullName, directory, null, FileActivity.DirectoryDeleted); return(true); }