0 votes
by (120 points)

What is required in code besides?
dim ftp1 as new rebex.net.ftp()
...
ftp1.GetFileDateTime(remotepath)
to change the time to MLST
(ftp1.settings.) in VB.net does not exist. That was the answer for fixing C#. We are using VB.NET.

Mine is an older version.

Thanks.

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (58.9k points)
edited by

Hello,

ftp.GetFileDateTime(remotepath) method automatically uses MLST command since version 2012R2 (if supported by the server). To take advantage of this, an update to at least version 2012R2 is required.

For more details on how to get the new version see my comment to your comment at the original question.

With 2012R1 and earlier, you can use the following method to determine file date/time using MLST command:

    Public Ahared Function GetFileDateTime(ftp As Ftp, path As String) as DateTime
        ftp.SendCommand("MLST " & path)
        Dim res As ftpresponse = ftp.ReadResponse()
        If res.Group <> 2 Then Throw New FtpException(res)

        dim facts As String = res.Raw.Split(Chr(10))(1).Trim()
        Dim raw() As String = { facts }
        Dim items = New FtpItemCollection(raw, FtpListingType.MachineProcessingList)
        Return items(0).LastWriteTime.Value
    End Function
by (120 points)
I appreciate your answer, which was already given.  My question was actually not what is new in the product but what is the workaround for the older version?

So using the old version there was no way to get the right FTP time of the remote server, basically it was not complete in its ability to get the correct time date?
by (148k points)
Rebex FTP/SSL 2012 R1 and earlier used MDTM command (an extension to the original FTP protocol) to determine file date/time with most FTP servers. This returns an UTC time for all servers that implement the MDTM command according to its specification, which states that GMT (UTC) time zone is to be used (see https://tools.ietf.org/html/rfc3659#page-11). Unfortunately, not all server vendors implemented MDTM according to the specification (see http://blog.rebex.net/file-modification-date-and-time-in-ftp/).

Rebex FTP/SSL 2012 R2 and later use MLST command (another extension to the FTP protocol) by default when available, which is more reliable (we are not currently aware of any FTP servers using a wrong time zone in MLST responses).

However, the old version works fine with servers that adhere to the MDTM specification. With these servers, it returns an UTC date/time (even though marked as 'Unspecified').

I added a code that uses MLST to determine file date/time with 2012 R1 and earlier to Tomas' answer.
...