When using the TIdFTP.SetModTime function, why do I get a "no such file or directory" but the file exists.

Previous  Top  Next

The TIdFTP.SetModTime uses a FTP command called MDTM.  That command requests the last modified date on a file and this is what Extensions to FTP (draft-ietf-ftpext-mlst-16) says.  Unfortunately, some servers and some clients also use (I should say abuse), that command to set the last modified file date.   Indy's FTP client and server do support this abuse of the MDTM for compatibility reasons.  If the server does support a "MFMT" command, Indy will use that instead of MDTM but most servers do not support that command.


The syntax for getting a file date is:


MDTM MyFileName


and to set the file date, the syntax usually is something like:


MDTM filedate MyFileName


If a server doesn't support setting the file date with MDTM, the server may interpret the filedate as the start of the filename.  Since a file with such a name probably does not exist, you get that error about a file not existing.


So all I can say is that server does NOT support setting the file date with the MDTM command.   The confusion is the consequences of someone else's poor design.


The ultimate solution to this problem is if more servers support the commands from The 'MFxx' Command Extensions for FTP (draft-somers-ftp-mfxx-01) IETF Internet Draft.  That draft also provides a solution to another problem I see with FTP but that's another blog entry I may make someday.