void OnFileRemoving(FileCancelEventArgs e)
 {
     if (FileRemoving != null)
     {
         FileRemoving(this, e);
     }
 }
        /// <summary>
        /// Fires the event handlers for a file being created.
        /// </summary>
        /// <param name="fileName">The name of the file being created. This should be a fully qualified path.</param>
        /// <param name="isDirectory">Set to true if this is a directory</param>
        /// <returns>True if the operation can proceed, false if an event handler cancelled the operation.</returns>
        public bool FireFileReplacing(string fileName, bool isDirectory)
        {
            FileCancelEventArgs e = new FileCancelEventArgs(fileName, isDirectory);

            if (FileReplacing != null)
            {
                FileReplacing(this, e);
            }
            return(!e.Cancel);
        }
        /// <summary>
        /// Removes a file, raising the appropriate events. This method may show message boxes.
        /// </summary>
        public void RemoveFile(string fileName, bool isDirectory)
        {
            FileCancelEventArgs eargs = new FileCancelEventArgs(fileName, isDirectory);

            OnFileRemoving(eargs);
            if (eargs.Cancel)
            {
                return;
            }
            if (!eargs.OperationAlreadyDone)
            {
                if (isDirectory)
                {
                    try {
                        if (Directory.Exists(fileName))
                        {
                            if (SD.FileService.DeleteToRecycleBin)
                            {
                                NativeMethods.DeleteToRecycleBin(fileName);
                            }
                            else
                            {
                                Directory.Delete(fileName, true);
                            }
                        }
                    } catch (Exception e) {
                        MessageService.ShowHandledException(e, "Can't remove directory " + fileName);
                    }
                }
                else
                {
                    try {
                        if (File.Exists(fileName))
                        {
                            if (SD.FileService.DeleteToRecycleBin)
                            {
                                NativeMethods.DeleteToRecycleBin(fileName);
                            }
                            else
                            {
                                File.Delete(fileName);
                            }
                        }
                    } catch (Exception e) {
                        MessageService.ShowHandledException(e, "Can't remove file " + fileName);
                    }
                }
            }
            OnFileRemoved(new FileEventArgs(fileName, isDirectory));
        }
		/// <summary>
		/// Fires the event handlers for a file being created.
		/// </summary>
		/// <param name="fileName">The name of the file being created. This should be a fully qualified path.</param>
		/// <param name="isDirectory">Set to true if this is a directory</param>
		/// <returns>True if the operation can proceed, false if an event handler cancelled the operation.</returns>
		public bool FireFileReplacing(string fileName, bool isDirectory)
		{
			FileCancelEventArgs e = new FileCancelEventArgs(fileName, isDirectory);
			if (FileReplacing != null) {
				FileReplacing(this, e);
			}
			return !e.Cancel;
		}
		void OnFileRemoving(FileCancelEventArgs e)
		{
			if (FileRemoving != null) {
				FileRemoving(this, e);
			}
		}
		/// <summary>
		/// Removes a file, raising the appropriate events. This method may show message boxes.
		/// </summary>
		public void RemoveFile(string fileName, bool isDirectory)
		{
			FileCancelEventArgs eargs = new FileCancelEventArgs(fileName, isDirectory);
			OnFileRemoving(eargs);
			if (eargs.Cancel)
				return;
			if (!eargs.OperationAlreadyDone) {
				if (isDirectory) {
					try {
						if (Directory.Exists(fileName)) {
							if (SD.FileService.DeleteToRecycleBin)
								NativeMethods.DeleteToRecycleBin(fileName);
							else
								Directory.Delete(fileName, true);
						}
					} catch (Exception e) {
						MessageService.ShowHandledException(e, "Can't remove directory " + fileName);
					}
				} else {
					try {
						if (File.Exists(fileName)) {
							if (SD.FileService.DeleteToRecycleBin)
								NativeMethods.DeleteToRecycleBin(fileName);
							else
								File.Delete(fileName);
						}
					} catch (Exception e) {
						MessageService.ShowHandledException(e, "Can't remove file " + fileName);
					}
				}
			}
			OnFileRemoved(new FileEventArgs(fileName, isDirectory));
		}