Exemplo n.º 1
0
        /// <inheritdoc/>
        public void DeleteMediaFolder(int librarySiteID, string libraryName, string folderName)
        {
            // Gets the media library
            string siteName        = SiteInfoProvider.GetSiteName(librarySiteID);
            var    existingLibrary = MediaLibraryInfoProvider.GetMediaLibraryInfo(libraryName, siteName);

            if (existingLibrary != null)
            {
                // Deletes the "NewFolder" folder within the media library
                MediaLibraryInfoProvider.DeleteMediaLibraryFolder(siteName, existingLibrary.LibraryID, folderName, false);
            }
        }
Exemplo n.º 2
0
    /// <summary>
    /// Deletes media folder. Called when the "Delete folder" button is pressed.
    /// Expects the CreateMediaFolder method to be run first.
    /// </summary>
    private bool DeleteMediaFolder()
    {
        // Get media library
        MediaLibraryInfo library = MediaLibraryInfoProvider.GetMediaLibraryInfo("MyNewLibrary", SiteContext.CurrentSiteName);

        if (library != null)
        {
            // Delete new media folder object
            MediaLibraryInfoProvider.DeleteMediaLibraryFolder(CurrentSiteName, library.LibraryID, "MyNewFolder", false);

            return(true);
        }

        return(false);
    }
Exemplo n.º 3
0
    protected void btnOk_Click(object sender, EventArgs e)
    {
        MediaLibraryInfo libInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(this.LibraryID);

        if (libInfo != null)
        {
            // Check 'Folder delete' permission
            if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(libInfo, "folderdelete"))
            {
                this.lblError.Text    = MediaLibraryHelper.GetAccessDeniedMessage("folderdelete");
                this.lblError.Visible = true;
                return;
            }

            try
            {
                // Delete folder and all files within
                MediaLibraryInfoProvider.DeleteMediaLibraryFolder(CMSContext.CurrentSiteName, this.LibraryID, this.FolderPath, false);

                // Get path of the parent folder of the currently deleted folder
                this.FolderPath           = DirectoryHelper.CombinePath(this.LibraryFolder, this.FolderPath);
                this.mDeletedFolderParent = this.FolderPath.Remove(this.FolderPath.LastIndexOf("\\"));

                // Let the parent control know the folder was deleted
                if (OnFolderDeleted != null)
                {
                    OnFolderDeleted(this.mDeletedFolderParent);
                }

                this.lblError.Visible = false;
            }
            catch (Exception ex)
            {
                // Display an error to the user
                this.lblError.Text    = GetString("general.erroroccurred") + " " + ex.Message;
                this.lblError.Visible = true;
            }
        }
    }