상속: FtpFileEventArgs
예제 #1
0
 internal protected virtual void InvokeOnRename(FtpRenameEventArgs e)
 {
     if (this.OnRename != null)
         this.OnRename(this, e);
 }
예제 #2
0
        public static void Cmd_RNTO(Object sender, CommandEventArgs e)
        {
            FtpSession lSession = (FtpSession)e.Session;

            if (lSession.State == FtpState.LoggedIn)
            {
                if ((e.AllParameters.Length == 0) || (!ValidFilename(e.AllParameters)))
                {
                    e.Connection.WriteLine("501 Syntax error in parameters or arguments.");
                    return;
                }

                if (lSession.RenameFrom == null)
                {
                    e.Connection.WriteLine("500 Bad sequence of commands.");
                    return;
                }

                String lNewDir = e.AllParameters;

                if (lNewDir.StartsWith("/"))
                {
                    lNewDir = ValidateDirectory(lNewDir);
                }
                else
                {
                    String lTemp = lSession.Directory;
                    if (!lTemp.EndsWith("/"))
                        lTemp = lTemp + "/";
                    lNewDir = ValidateDirectory(lTemp + lNewDir);
                }

                FtpRenameEventArgs lEventArgs = new FtpRenameEventArgs(e.Session, e.Connection, e.Server);
                lEventArgs.FileName = lSession.RenameFrom;
                lSession.RenameFrom = null;
                lEventArgs.NewFileName = lNewDir;
                try
                {
                    ((FtpServer)e.Server).InvokeOnRename(lEventArgs);
                }
                catch (FtpException ex)
                {
                    e.Connection.WriteLine(ex.ToString());
                    return;
                }
                catch
                {
                    e.Connection.WriteLine("500 Internal Error");
                    return;
                }

                if (lEventArgs.Ok)
                    e.Connection.WriteLine("250 Rename successful");
                else
                    e.Connection.WriteLine("550 Permission Denied");
            }
            else
            {
                e.Connection.WriteLine("503 Bad sequence of commands.");
            }
        }
예제 #3
0
		protected override void InvokeOnRename(FtpRenameEventArgs ea)
		{
			VirtualFtpSession lSession = (VirtualFtpSession)ea.Session;
			IFtpFolder lFolder;
			string lFilename;

			lSession.CurrentFolder.FindBaseFolderForFilename(ea.FileName, out lFolder, out lFilename, lSession);
			lFolder.RenameFileOrFolder(lFilename, ea.NewFileName, lSession);
			ea.Ok = true;
		}