0 votes
by (620 points)
edited by

The FileTransferClient.SetFileDateTimeAsync returns "The requested operation is not supported." but FileTransferClient.SendCommandAsync "MFMT 20020717210715 xyz.txt" works.
Is this a bug?

The log shows this:
Command: STOR /index.html
Response: 150 Accepted data connection
Response: 226-File successfully transferred
Response: 226 0.024 seconds (measured here), 214.37 Kbytes per second
Command: MDTM /index.html
Response: 213 20200930003311
Command: MDTM 20200901144622 /index.html
Response: 550 Can't check for file existence

by (148k points)
`SetFileDateTime` methods only use MFMT if the server announced support for it in its FEAT response. Could you please post that part of the log as well?
by (620 points)
Info:     Connecting to ftp.dlptest.com:21 using Ftp.
Info:     Using proxy none.
Response: 220-#########################################################
Response: 220-Please upload your web files to the public_html directory.
Response: 220-Note that letters are case sensitive.
Response: 220-#########################################################
Response: 220 This is a private system - No anonymous login
Command:  AUTH TLS
Response: 234 AUTH TLS OK.
Command:  USER dlpuser@dlptest.com
Response: 331 User dlpuser@dlptest.com OK. Password required
Command:  PASS **********
Response: 230-Your bandwidth usage is restricted
Response: 230 OK. Current restricted directory is /
Command:  FEAT
Response: 211-Extensions supported:
Response:  EPRT
Response:  IDLE
Response:  MDTM
Response:  SIZE
Response:  MFMT
Response:  REST STREAM
Response:  MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
Response:  MLSD
Response:  AUTH TLS
Response:  PBSZ
Response:  PROT
Response:  UTF8
Response:  TVFS
Response:  ESTA
Response:  PASV
Response:  EPSV
Response:  SPSV
Response:  ESTP
Response: 211 End.
Command:  OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Command:  OPTS MLST type;size;modify;UNIX.mode;
Response: 200  MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
by (620 points)
Information to access the site:
https://dlptest.com/ftp-test/

1 Answer

0 votes
by (148k points)

I tried running the following code and it did use MFMT command:

var ftp = new Ftp();
ftp.LogWriter = new ConsoleLogWriter(LogLevel.Debug);
ftp.Settings.SslServerName = "siteground.biz";
ftp.Connect("ftp.dlptest.com", SslMode.Explicit);
ftp.Login("dlpuser@dlptest.com", "...");
ftp.SetFileDateTime("myfile.txt", DateTime.Now);

(I had to explicitly specify the server name because the server is misconfigured - its certificate does not match the server name.)

Resulting log:

2020-09-30 09:53:16.555 INFO Ftp(1)[11] Command: MFMT 20200930075316 myfile.txt
2020-09-30 09:53:16.676 INFO Ftp(1)[11] Response: 550 utime(myfile.txt): No such file or directory

Please make sure you are not disabling MFMT in your code by modifying the EnabledExtensions property:

ftp.EnabledExtensions &= ~FtpExtensions.ModifyFileModificationTime;

Or enable it again before calling SetFileDateTime:

ftp.EnabledExtensions |= FtpExtensions.ModifyFileModificationTime;
by (620 points)
Thanks Lukas,
No, I didn't change any of the EnabledExtensions.
I think it is failing only if you do a file transfer first.
ftp.PutFile(@"c:\myfile.txt", "myfile.txt");
by (148k points)
I tried this using the latest version of Rebex FTP/SSL:

var ftp = new Ftp();
ftp.LogWriter = new ConsoleLogWriter(LogLevel.Debug);
ftp.Settings.SslServerName = "siteground.biz"; // works around misconfigured server certificate
ftp.Connect("ftp.dlptest.com", SslMode.Explicit);
ftp.Login("dlpuser@dlptest.com", "...");
ftp.PutFile(@"c:\data\myfile.txt", "myfile.txt");
ftp.SetFileDateTime("myfile.txt", DateTime.Now);
ftp.GetRawList();

The log shows that MFMT was in fact used:

2020-09-30 10:32:25.467 INFO Ftp(1)[1] Info: Connecting to ftp.dlptest.com:21 using Ftp.
2020-09-30 10:32:25.476 INFO Ftp(1)[1] Info: Assembly: Rebex.Ftp 2020 R3 for .NET Standard 2.1 (Trial)
2020-09-30 10:32:25.482 INFO Ftp(1)[1] Info: Platform: Windows 10.0.19041 64-bit; CLR: .NET Core 3.1.8
2020-09-30 10:32:25.487 INFO Ftp(1)[1] Info: Using proxy none.
2020-09-30 10:32:25.789 INFO Ftp(1)[1] Response: 220-#########################################################
2020-09-30 10:32:25.791 INFO Ftp(1)[1] Response: 220-Please upload your web files to the public_html directory.
2020-09-30 10:32:25.792 INFO Ftp(1)[1] Response: 220-Note that letters are case sensitive.
2020-09-30 10:32:25.792 INFO Ftp(1)[1] Response: 220-#########################################################
2020-09-30 10:32:25.793 INFO Ftp(1)[1] Response: 220 This is a private system - No anonymous login
2020-09-30 10:32:25.804 INFO Ftp(1)[1] Command: AUTH TLS
2020-09-30 10:32:25.925 INFO Ftp(1)[1] Response: 234 AUTH TLS OK.
2020-09-30 10:32:26.265 INFO Ftp(1)[1] TLS: Negotiating TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2020-09-30 10:32:26.555 INFO Ftp(1)[1] TLS: Connection secured using cipher: TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2020-09-30 10:32:26.561 INFO Ftp(1)[1] Command: USER dlpuser@dlptest.com
2020-09-30 10:32:26.684 INFO Ftp(1)[1] Response: 331 User dlpuser@dlptest.com OK. Password required
2020-09-30 10:32:26.687 INFO Ftp(1)[1] Command: PASS **********
2020-09-30 10:32:26.832 INFO Ftp(1)[1] Response: 230-Your bandwidth usage is restricted
2020-09-30 10:32:26.833 INFO Ftp(1)[1] Response: 230 OK. Current restricted directory is /
2020-09-30 10:32:26.835 INFO Ftp(1)[1] Command: FEAT
2020-09-30 10:32:26.955 INFO Ftp(1)[1] Response: 211-Extensions supported:
2020-09-30 10:32:26.957 INFO Ftp(1)[1] Response:  EPRT
2020-09-30 10:32:26.958 INFO Ftp(1)[1] Response:  IDLE
2020-09-30 10:32:26.958 INFO Ftp(1)[1] Response:  MDTM
2020-09-30 10:32:26.959 INFO Ftp(1)[1] Response:  SIZE
2020-09-30 10:32:26.959 INFO Ftp(1)[1] Response:  MFMT
2020-09-30 10:32:26.959 INFO Ftp(1)[1] Response:  REST STREAM
2020-09-30 10:32:26.960 INFO Ftp(1)[1] Response:  MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
2020-09-30 10:32:26.960 INFO Ftp(1)[1] Response:  MLSD
2020-09-30 10:32:26.961 INFO Ftp(1)[1] Response:  AUTH TLS
2020-09-30 10:32:26.962 INFO Ftp(1)[1] Response:  PBSZ
2020-09-30 10:32:26.963 INFO Ftp(1)[1] Response:  PROT
2020-09-30 10:32:26.964 INFO Ftp(1)[1] Response:  UTF8
2020-09-30 10:32:26.965 INFO Ftp(1)[1] Response:  TVFS
2020-09-30 10:32:26.966 INFO Ftp(1)[1] Response:  ESTA
2020-09-30 10:32:26.966 INFO Ftp(1)[1] Response:  PASV
2020-09-30 10:32:26.967 INFO Ftp(1)[1] Response:  EPSV
2020-09-30 10:32:26.968 INFO Ftp(1)[1] Response:  SPSV
2020-09-30 10:32:26.969 INFO Ftp(1)[1] Response:  ESTP
2020-09-30 10:32:26.970 INFO Ftp(1)[1] Response: 211 End.
2020-09-30 10:32:26.979 INFO Ftp(1)[1] Command: OPTS UTF8 ON
2020-09-30 10:32:27.100 INFO Ftp(1)[1] Response: 200 OK, UTF-8 enabled
2020-09-30 10:32:27.104 INFO Ftp(1)[1] Command: OPTS MLST type;size;modify;UNIX.mode;
2020-09-30 10:32:27.225 INFO Ftp(1)[1] Response: 200  MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;
2020-09-30 10:32:27.249 INFO Ftp(1)[1] Command: PBSZ 0
2020-09-30 10:32:27.370 INFO Ftp(1)[1] Response: 200 PBSZ=0
2020-09-30 10:32:27.372 INFO Ftp(1)[1] Command: PROT P
2020-09-30 10:32:27.493 INFO Ftp(1)[1] Response: 200 Data protection level set to "private"
2020-09-30 10:32:27.498 INFO Ftp(1)[1] Command: TYPE I
2020-09-30 10:32:27.619 INFO Ftp(1)[1] Response: 200 TYPE is now 8-bit binary
2020-09-30 10:32:27.624 INFO Ftp(1)[1] Command: PASV
2020-09-30 10:32:27.746 INFO Ftp(1)[1] Response: 227 Entering Passive Mode (35,209,241,59,135,218)
2020-09-30 10:32:27.880 INFO Ftp(1)[1] Command: STOR myfile.txt
2020-09-30 10:32:28.001 INFO Ftp(1)[1] Response: 150 Accepted data connection
2020-09-30 10:32:28.008 INFO Ftp(1)[1] TLS: Data connection: Trying to resume session.
2020-09-30 10:32:28.131 INFO Ftp(1)[1] TLS: Data connection: Negotiating TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2020-09-30 10:32:28.133 INFO Ftp(1)[1] TLS: Data connection: Resuming session.
2020-09-30 10:32:28.135 INFO Ftp(1)[1] TLS: Data connection: Connection secured using cipher: TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2020-09-30 10:32:28.270 INFO Ftp(1)[1] Response: 226-File successfully transferred
2020-09-30 10:32:28.272 INFO Ftp(1)[1] Response: 226 0.014 seconds (measured here), 294.49 bytes per second
2020-09-30 10:32:28.277 INFO Ftp(1)[1] Command: MFMT 20200930083228 myfile.txt
2020-09-30 10:32:28.398 INFO Ftp(1)[1] Response: 213 UTIME OK
2020-09-30 10:32:28.406 INFO Ftp(1)[1] Command: TYPE A
2020-09-30 10:32:28.527 INFO Ftp(1)[1] Response: 200 TYPE is now ASCII
2020-09-30 10:32:28.530 INFO Ftp(1)[1] Command: PASV
2020-09-30 10:32:28.652 INFO Ftp(1)[1] Response: 227 Entering Passive Mode (35,209,241,59,135,63)
2020-09-30 10:32:28.779 INFO Ftp(1)[1] Command: LIST
2020-09-30 10:32:28.901 INFO Ftp(1)[1] Response: 150 Accepted data connection
2020-09-30 10:32:28.905 INFO Ftp(1)[1] TLS: Data connection: Trying to resume session.
2020-09-30 10:32:29.027 INFO Ftp(1)[1] TLS: Data connection: Negotiating TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2020-09-30 10:32:29.031 INFO Ftp(1)[1] TLS: Data connection: Resuming session.
2020-09-30 10:32:29.032 INFO Ftp(1)[1] TLS: Data connection: Connection secured using cipher: TLS 1.2, RSA with ephemeral ECDH, AES with 256-bit key in GCM mode, AEAD.
2020-09-30 10:32:29.441 INFO Ftp(1)[1] Response: 226-Options: -a -l
2020-09-30 10:32:29.442 INFO Ftp(1)[1] Response: 226 12 matches total

Could you try running the same code yourself?
by (620 points)
Sorry Lucas,
I finally figured out why.
I had the ftp.Settings.DoNotDetectFeatures = true;
But it is weird that calling SetFileDateTime in that case will cause those MDTM  commands to be sent (see my first post's log)
by (148k points)
Thanks for letting us know!
Sorry for not mentioning that option as well. I thought it was not the reason because when DoNotDetectFeatures is true, there is no FEAT command/response in the log at all.
by (620 points)
Thanks for your help!
...