/// <inheritdoc/>
        public override Task <IFtpResponse?> Process(FtpCommand command, CancellationToken cancellationToken)
        {
            var transferMode = FtpTransferMode.Parse(command.Argument);

            FtpResponse response;

            if (transferMode.FileType == FtpFileType.Ascii)
            {
                response = new FtpResponse(200, T("ASCII transfer mode active."));
            }
            else if (transferMode.IsBinary)
            {
                response = new FtpResponse(200, T("Binary transfer mode active."));
            }
            else
            {
                response = new FtpResponse(504, T("Mode {0} not supported.", command.Argument));
            }

            if (response.Code == 200)
            {
                var transferModeFeature = Connection.Features.Get <ITransferConfigurationFeature>();
                transferModeFeature.TransferMode = transferMode;
            }

            return(Task.FromResult <IFtpResponse?>(response));
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public override Task <FtpResponse> Process(FtpCommand command, CancellationToken cancellationToken)
        {
            var transferMode = FtpTransferMode.Parse(command.Argument);

            FtpResponse response;

            if (transferMode.FileType == FtpFileType.Ascii)
            {
                response = new FtpResponse(200, "ASCII transfer mode active.");
            }
            else if (transferMode.IsBinary)
            {
                response = new FtpResponse(200, "Binary transfer mode active.");
            }
            else
            {
                response = new FtpResponse(504, $"Mode {command.Argument} not supported.");
            }

            if (response.Code == 200)
            {
                Connection.Data.TransferMode = transferMode;
            }

            return(Task.FromResult(response));
        }
Ejemplo n.º 3
0
 public override void Process(params string[] args)
 {
     client.LoginInfo.transferMode = FtpTransferMode.Parse(args[0]);
     if (client.LoginInfo.transferMode.FileType == FtpFileType.Ascii)
     {
         client.Send(ResultCode.Success.ConvertString("ASCII transfer mode active."));
     }
     else if (client.LoginInfo.transferMode.IsBinary)
     {
         client.Send(ResultCode.Success.ConvertString("Binary transfer mode active."));
     }
     else
     {
         throw new ArgumentErrorException();
     }
 }