Jump to content

How to Retrieve Modified date from FTP site?


Recommended Posts

Does anyone have any code that will retrieve the modified date of a file on an FTP site? Or code that is close that I can modify? I have most of the FTP connection code I just don't know how to retrieve the mod. date.

I did a bit of research about this the last time you asked but LIFE got in the way and I didn't get back.

The only thing I've found is

_FTP_ListToArrayEx
Get names, sizes, attributes aand times of files/dir of current remote directory.

it returns and array containing

Array[0][0] = number of found entries

Array[x][0] Filename
Array[x][1] Filesize
Array[x][2] FileAttribute
Array[x][3] File Modification datetime
Array[x][4] File Creation datetime
Array[x][5] File Access datetime

You could write a function that takes the path and file name. The function could then search through the array to find the file and get the date.

Be careful the testing I did produced the wrong format for date (day & month reversed), however it's to be fixed in the next release.

Let me know how you go.

Link to comment
Share on other sites

I too thought of this method, but when I looked at the function, _FTP_ListToArrayEx(), it doesn't seem to have a path parameters. So it seems to only retrieve the mod. date of the files in the directory that you make the _FTPConnection() connection to. I also thought that I would look to see how that function was able to get the mod. date, but I was unable to follow it all that well. If you know how to get the _FTP_ListToArrayEx() function to "inventory" different directories, please let me know.

Thanks for you time!

Link to comment
Share on other sites

I too thought of this method, but when I looked at the function, _FTP_ListToArrayEx(), it doesn't seem to have a path parameters. So it seems to only retrieve the mod. date of the files in the directory that you make the _FTPConnection() connection to. I also thought that I would look to see how that function was able to get the mod. date, but I was unable to follow it all that well. If you know how to get the _FTP_ListToArrayEx() function to "inventory" different directories, please let me know.

Thanks for you time!

#include <FTPEx.au3>
#include <Array.au3>

$server = ''
$username = ''
$pass = ''
$directory = ""

$Open = _FTP_Open('MyFTP Control')
$Conn = _FTP_Connect($Open, $server, $username, $pass)
_FTP_DirSetCurrent($Conn, $directory)

$aFile = _FTP_ListToArrayEx($Conn, 2,0,0)
;Parameters
;$l_FTPSession as returned by _FTP_Connect().
;$Return_type [optional] 0 = Both Files and Directories, 1 = Directories, 2 = Files.
;$l_Flags [optional] see _FTP_FindFileFirst().
;$b_Fmt [optional] type on the date strings : 1 = yyyy/mm/dd, 0 = mm/dd/yyyy.  (ERROR here***)
;$l_Context [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.
If $aFile[0][0] = 0 Then
    MsgBox(0,"ERROR: _FTP_ListToArrayEx","command failed")
Else
    ConsoleWrite('array count = ' & UBound($aFile)& '  -> Error code: ' & @error & @CRLF)
    _ArrayDisplay($aFile)
EndIf

;ConsoleWrite('$Filename = ' & $aFile[1] & @crlf)

$Ftpc = _FTP_Close($Open)

That should give you a good start. :idea:

Good Luck!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...