0 votes
by (120 points)
edited

Hi,

I was trying to get the latest file from FTP server using the ftp.GetFileDateTime function but I am getting below error. Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Rebex.Net.FtpException: command MDTM is not available for DAT.G(550). Can anyone help me to get this fix. I want to get the latest file from available files. Thanks for your help!

Regards, Abhiyanta

1 Answer

0 votes
by (144k points)
edited

It looks like you encountered one of the FTP server that don't support the MDTM command (used to retrieve a date/time of a single file by GetFileDateTime method. This command was not originally a part of FTP protocol, and some servers have never added support for it.

As a workaround, you would have to use the GetList method to retrieve a list of all files in a directory. Then, find the latest file in the list - the returned list is a list of FtpItem objects with LastWriteTime property set.

...