Ejemplo n.º 1
0
 void OnFileCopying(FileRenamingEventArgs e)
 {
     if (FileCopying != null)
     {
         FileCopying(this, e);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Renames or moves a file, raising the appropriate events. This method may show message boxes.
 /// </summary>
 public bool RenameFile(string oldName, string newName, bool isDirectory)
 {
     if (FileUtility.IsEqualFileName(oldName, newName))
     {
         return(false);
     }
     FileChangeWatcher.DisableAllChangeWatchers();
     try {
         FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
         OnFileRenaming(eargs);
         if (eargs.Cancel)
         {
             return(false);
         }
         if (!eargs.OperationAlreadyDone)
         {
             try {
                 if (isDirectory && Directory.Exists(oldName))
                 {
                     if (Directory.Exists(newName))
                     {
                         MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
                         return(false);
                     }
                     Directory.Move(oldName, newName);
                 }
                 else if (File.Exists(oldName))
                 {
                     if (File.Exists(newName))
                     {
                         MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
                         return(false);
                     }
                     File.Move(oldName, newName);
                 }
             } catch (Exception e) {
                 if (isDirectory)
                 {
                     MessageService.ShowHandledException(e, "Can't rename directory " + oldName);
                 }
                 else
                 {
                     MessageService.ShowHandledException(e, "Can't rename file " + oldName);
                 }
                 return(false);
             }
         }
         OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory));
         return(true);
     } finally {
         FileChangeWatcher.EnableAllChangeWatchers();
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Copies a file, raising the appropriate events. This method may show message boxes.
        /// </summary>
        public bool CopyFile(string oldName, string newName, bool isDirectory, bool overwrite)
        {
            if (FileUtility.IsEqualFileName(oldName, newName))
            {
                return(false);
            }
            FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);

            OnFileCopying(eargs);
            if (eargs.Cancel)
            {
                return(false);
            }
            if (!eargs.OperationAlreadyDone)
            {
                try {
                    if (isDirectory && Directory.Exists(oldName))
                    {
                        if (!overwrite && Directory.Exists(newName))
                        {
                            MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
                            return(false);
                        }
                        FileUtility.DeepCopy(oldName, newName, overwrite);
                    }
                    else if (File.Exists(oldName))
                    {
                        if (!overwrite && File.Exists(newName))
                        {
                            MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
                            return(false);
                        }
                        File.Copy(oldName, newName, overwrite);
                    }
                } catch (Exception e) {
                    if (isDirectory)
                    {
                        MessageService.ShowHandledException(e, "Can't copy directory " + oldName);
                    }
                    else
                    {
                        MessageService.ShowHandledException(e, "Can't copy file " + oldName);
                    }
                    return(false);
                }
            }
            OnFileCopied(new FileRenameEventArgs(oldName, newName, isDirectory));
            return(true);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Renames or moves a file, raising the appropriate events. This method may show message boxes.
 /// </summary>
 public bool RenameFile(string oldName, string newName, bool isDirectory)
 {
     if (FileUtility.IsEqualFileName(oldName, newName))
     {
         return(false);
     }
     FileChangeWatcher.DisableAllChangeWatchers();
     try {
         FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
         OnFileRenaming(eargs);
         if (eargs.Cancel)
         {
             return(false);
         }
         if (!eargs.OperationAlreadyDone)
         {
             try {
                 if (FileHelpers.CheckRenameOrReplacePossible(eargs))
                 {
                     if (isDirectory)
                     {
                         Directory.Move(oldName, newName);
                     }
                     else
                     {
                         File.Move(oldName, newName);
                     }
                 }
             } catch (Exception e) {
                 if (isDirectory)
                 {
                     MessageService.ShowHandledException(e, "Can't rename directory " + oldName);
                 }
                 else
                 {
                     MessageService.ShowHandledException(e, "Can't rename file " + oldName);
                 }
                 return(false);
             }
         }
         OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory));
         return(true);
     } finally {
         FileChangeWatcher.EnableAllChangeWatchers();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Renames or moves a file, raising the appropriate events. This method may show message boxes.
 /// </summary>
 public bool RenameFile(string oldName, string newName, bool isDirectory)
 {
     if (string.Equals(FileUtility.NormalizePath(oldName),
                       FileUtility.NormalizePath(newName),
                       StringComparison.Ordinal))
     {
         return(false);
     }
     FileChangeWatcher.DisableAllChangeWatchers();
     try {
         FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
         OnFileRenaming(eargs);
         if (eargs.Cancel)
         {
             return(false);
         }
         if (!eargs.OperationAlreadyDone)
         {
             try {
                 if (isDirectory)
                 {
                     Directory.Move(oldName, newName);
                 }
                 else
                 {
                     File.Move(oldName, newName);
                 }
             } catch (Exception e) {
                 if (isDirectory)
                 {
                     MessageService.ShowHandledException(e, "Can't rename directory " + oldName);
                 }
                 else
                 {
                     MessageService.ShowHandledException(e, "Can't rename file " + oldName);
                 }
                 return(false);
             }
         }
         OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory));
         return(true);
     } finally {
         FileChangeWatcher.EnableAllChangeWatchers();
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Copies a file, raising the appropriate events. This method may show message boxes.
        /// </summary>
        public bool CopyFile(string oldName, string newName, bool isDirectory, bool overwrite)
        {
            if (FileUtility.IsEqualFileName(oldName, newName))
            {
                return(false);
            }
            FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);

            OnFileCopying(eargs);
            if (eargs.Cancel)
            {
                return(false);
            }
            if (!eargs.OperationAlreadyDone)
            {
                try {
                    if (FileHelpers.CheckRenameOrReplacePossible(eargs, overwrite))
                    {
                        if (isDirectory)
                        {
                            FileUtility.DeepCopy(oldName, newName, overwrite);
                        }
                        else
                        {
                            File.Copy(oldName, newName, overwrite);
                        }
                    }
                } catch (Exception e) {
                    if (isDirectory)
                    {
                        MessageService.ShowHandledException(e, "Can't copy directory " + oldName);
                    }
                    else
                    {
                        MessageService.ShowHandledException(e, "Can't copy file " + oldName);
                    }
                    return(false);
                }
            }
            OnFileCopied(new FileRenameEventArgs(oldName, newName, isDirectory));
            return(true);
        }
Ejemplo n.º 7
0
		void OnFileCopying(FileRenamingEventArgs e)
		{
			if (FileCopying != null) {
				FileCopying(this, e);
			}
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Copies a file, raising the appropriate events. This method may show message boxes.
		/// </summary>
		public bool CopyFile(string oldName, string newName, bool isDirectory, bool overwrite)
		{
			if (FileUtility.IsEqualFileName(oldName, newName))
				return false;
			FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
			OnFileCopying(eargs);
			if (eargs.Cancel)
				return false;
			if (!eargs.OperationAlreadyDone) {
				try {
					if (isDirectory && Directory.Exists(oldName)) {
						
						if (!overwrite && Directory.Exists(newName)) {
							MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
							return false;
						}
						FileUtility.DeepCopy(oldName, newName, overwrite);
						
					} else if (File.Exists(oldName)) {
						if (!overwrite && File.Exists(newName)) {
							MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
							return false;
						}
						File.Copy(oldName, newName, overwrite);
					}
				} catch (Exception e) {
					if (isDirectory) {
						MessageService.ShowHandledException(e, "Can't copy directory " + oldName);
					} else {
						MessageService.ShowHandledException(e, "Can't copy file " + oldName);
					}
					return false;
				}
			}
			OnFileCopied(new FileRenameEventArgs(oldName, newName, isDirectory));
			return true;
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Renames or moves a file, raising the appropriate events. This method may show message boxes.
		/// </summary>
		public bool RenameFile(string oldName, string newName, bool isDirectory)
		{
			if (FileUtility.IsEqualFileName(oldName, newName))
				return false;
			FileChangeWatcher.DisableAllChangeWatchers();
			try {
				FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
				OnFileRenaming(eargs);
				if (eargs.Cancel)
					return false;
				if (!eargs.OperationAlreadyDone) {
					try {
						if (isDirectory && Directory.Exists(oldName)) {
							
							if (Directory.Exists(newName)) {
								MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
								return false;
							}
							Directory.Move(oldName, newName);
							
						} else if (File.Exists(oldName)) {
							if (File.Exists(newName)) {
								MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}"));
								return false;
							}
							File.Move(oldName, newName);
						}
					} catch (Exception e) {
						if (isDirectory) {
							MessageService.ShowHandledException(e, "Can't rename directory " + oldName);
						} else {
							MessageService.ShowHandledException(e, "Can't rename file " + oldName);
						}
						return false;
					}
				}
				OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory));
				return true;
			} finally {
				FileChangeWatcher.EnableAllChangeWatchers();
			}
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Copies a file, raising the appropriate events. This method may show message boxes.
		/// </summary>
		public bool CopyFile(string oldName, string newName, bool isDirectory, bool overwrite)
		{
			if (FileUtility.IsEqualFileName(oldName, newName))
				return false;
			FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
			OnFileCopying(eargs);
			if (eargs.Cancel)
				return false;
			if (!eargs.OperationAlreadyDone) {
				try {
					if (FileHelpers.CheckRenameOrReplacePossible(eargs, overwrite)) {
						if (isDirectory) {
							FileUtility.DeepCopy(oldName, newName, overwrite);
						} else {
							File.Copy(oldName, newName, overwrite);
						}
					}
				} catch (Exception e) {
					if (isDirectory) {
						MessageService.ShowHandledException(e, "Can't copy directory " + oldName);
					} else {
						MessageService.ShowHandledException(e, "Can't copy file " + oldName);
					}
					return false;
				}
			}
			OnFileCopied(new FileRenameEventArgs(oldName, newName, isDirectory));
			return true;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Renames or moves a file, raising the appropriate events. This method may show message boxes.
		/// </summary>
		public bool RenameFile(string oldName, string newName, bool isDirectory)
		{
			if (FileUtility.IsEqualFileName(oldName, newName))
				return false;
			FileChangeWatcher.DisableAllChangeWatchers();
			try {
				FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
				OnFileRenaming(eargs);
				if (eargs.Cancel)
					return false;
				if (!eargs.OperationAlreadyDone) {
					try {
						if (FileHelpers.CheckRenameOrReplacePossible(eargs)) {
							if (isDirectory) {
								Directory.Move(oldName, newName);
							} else {
								File.Move(oldName, newName);
							}
						}
					} catch (Exception e) {
						if (isDirectory) {
							MessageService.ShowHandledException(e, "Can't rename directory " + oldName);
						} else {
							MessageService.ShowHandledException(e, "Can't rename file " + oldName);
						}
						return false;
					}
				}
				OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory));
				return true;
			} finally {
				FileChangeWatcher.EnableAllChangeWatchers();
			}
		}
Ejemplo n.º 12
0
 /// <summary>
 /// Renames or moves a file, raising the appropriate events. This method may show message boxes.
 /// </summary>
 public bool RenameFile(string oldName, string newName, bool isDirectory)
 {
     if (string.Equals(FileUtility.NormalizePath(oldName),
             FileUtility.NormalizePath(newName),
             StringComparison.Ordinal))
         return false;
     FileChangeWatcher.DisableAllChangeWatchers();
     try {
         FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory);
         OnFileRenaming(eargs);
         if (eargs.Cancel)
             return false;
         if (!eargs.OperationAlreadyDone) {
             try {
                 if (isDirectory) {
                     Directory.Move(oldName, newName);
                 } else {
                     File.Move(oldName, newName);
                 }
             } catch (Exception e) {
                 if (isDirectory) {
                     MessageService.ShowHandledException(e, "Can't rename directory " + oldName);
                 } else {
                     MessageService.ShowHandledException(e, "Can't rename file " + oldName);
                 }
                 return false;
             }
         }
         OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory));
         return true;
     } finally {
         FileChangeWatcher.EnableAllChangeWatchers();
     }
 }