예제 #1
0
        public override FileSystemExitCode PutFile(string localName, ref string remoteName, CopyFlags copyFlags)
        {
            bool   overWrite = (CopyFlags.Overwrite & copyFlags) != 0;
            string rmtName   = remoteName.Substring(1);

            if (File.Exists(rmtName) & !overWrite)
            {
                return(FileSystemExitCode.FileExists);
            }
            try {
                if ((CopyFlags.Move & copyFlags) != 0)
                {
                    MoveFileOptions options =
                        (overWrite) ? MoveFileOptions.ReplaceExisting : MoveFileOptions.None;
                    FileRoutines.MoveFile(new FileInfo(localName), new FileInfo(rmtName), options, OnCopyFile);
                }
                else
                {
                    CopyFileOptions options =
                        (overWrite) ? CopyFileOptions.None : CopyFileOptions.FailIfDestinationExists;
                    FileRoutines.CopyFile(new FileInfo(localName), new FileInfo(rmtName), options, OnCopyFile);
                }
                return(FileSystemExitCode.OK);
            } catch (Exception ex) {
                MessageBox.Show(
                    "File operation error:" + Environment.NewLine + ex.Message,
                    "LFS Plugin (PutFile)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(FileSystemExitCode.WriteError);
            }
        }
예제 #2
0
 public override FileSystemExitCode RenMovFile(string oldName, string newName, bool move, bool overwrite,
                                               RemoteInfo remoteInfo)
 {
     oldName = oldName.Substring(1);
     if (!File.Exists(oldName))
     {
         return(FileSystemExitCode.FileNotFound);
     }
     newName = newName.Substring(1);
     if (File.Exists(newName) & !overwrite)
     {
         return(FileSystemExitCode.FileExists);
     }
     try {
         if (move)
         {
             MoveFileOptions options =
                 (overwrite) ? MoveFileOptions.ReplaceExisting : MoveFileOptions.None;
             FileRoutines.MoveFile(new FileInfo(oldName), new FileInfo(newName),
                                   options, OnCopyFile);
         }
         else
         {
             CopyFileOptions options =
                 (overwrite) ? CopyFileOptions.None : CopyFileOptions.FailIfDestinationExists;
             FileRoutines.CopyFile(new FileInfo(oldName), new FileInfo(newName),
                                   options, OnCopyFile);
         }
         return(FileSystemExitCode.OK);
     } catch (IOException ex) {
         if (ex.Message.Equals(ErrorRequestAbortedMsg))
         {
             return(FileSystemExitCode.UserAbort);
         }
         if (ex.Message.Equals(ErrorFileNotFoundMsg))
         {
             return(FileSystemExitCode.FileNotFound);
         }
         MessageBox.Show(
             "File operation error:" + Environment.NewLine + ex.Message,
             "LFS Plugin (RenMovFile)", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(FileSystemExitCode.ReadError);
     }
 }