コード例 #1
0
 /// <summary>
 /// Deletes the items supplied in the <see cref="VirtualFileBaseCollection"/>.
 /// </summary>
 /// <param name="items">The items to delete.</param>
 public static void DeleteItems(VirtualFileBaseCollection items)
 {
     //Can only delete items inheriting from Unified[Directory/File]
     foreach (VirtualFileBase fileItem in items)
     {
         if (CanEdit(fileItem))
         {
             UnifiedDirectory directory = fileItem as UnifiedDirectory;
             if (directory != null)
             {
                 directory.Delete();
                 continue;
             }
             UnifiedFile file = fileItem as UnifiedFile;
             if (file != null)
             {
                 file.Delete();
                 continue;
             }
         }
         else
         {
             //TODO: What do we do with delete operation on unknown items.
             // Throw exception? Silently ignore? Logging!
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Handles the Click event of the ReplaceFile control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void ReplaceFile_Click(object sender, EventArgs e)
        {
            UnifiedFile temporaryFile   = FileSystemUtility.GetFile(FileManager.CurrentVirtualDirectory, TemporaryFileName) as UnifiedFile;
            UnifiedFile destinationFile = FileSystemUtility.GetFile(FileManager.CurrentVirtualDirectory, DestinationFileName) as UnifiedFile;

            if (temporaryFile != null && destinationFile != null)
            {
                try
                {
                    FileSystemUtility.WriteToFile(temporaryFile, destinationFile, CheckInComment.Text.ToSafeString());
                }
                catch (FileIsCheckedOutException)
                {
                    // File is versioned and checked out to someone else
                    Page.Validators.Add(new StaticValidator(Translate("/filemanager/errormessage/checkedout")));
                    return;
                }
                finally
                {
                    try
                    {
                        temporaryFile.Delete();
                    }
                    catch (Exception exception)
                    {
                        _log.Warn("Failed to delete temporary file " + temporaryFile.VirtualPath, exception);
                    }
                }

                ResetUploadForm();
                FileManager.LoadDefaultView(this);
            }
        }
コード例 #3
0
 /// <summary>
 /// Handles the Click event of the Cancel button to cancel the current action.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void CancelButton_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(TemporaryFileName))
     {
         // File was uploaded to a temporary location, but the replace was aborted.
         UnifiedFile tempFile = FileSystemUtility.GetFile(FileManager.CurrentVirtualDirectory, TemporaryFileName) as UnifiedFile;
         if (tempFile != null)
         {
             tempFile.Delete();
         }
         ResetUploadForm();
     }
     else
     {
         FileManager.LoadDefaultView(this);
     }
 }