Link to home
Start Free TrialLog in
Avatar of Jambyte
JambyteFlag for United States of America

asked on

how can i get the date of a file on a ftp server?

how can i get the date of a file on a ftp server?
Avatar of Alon Hirsch
Alon Hirsch
Flag of Australia image

Hi,

When you send an 'ls' query to an FTP site - you get the file name, date and size returned.
simply parse the data returned from the command and pick the date from that.

You will have to experiment a bit first.

HTH,
Alon
ASKER CERTIFIED SOLUTION
Avatar of Glowman
Glowman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jambyte

ASKER

when i try to call the Download sub i get an error highlighting MAX_PATH and saying: Compile error: Constatnt Expression required
Jambyte,

There are a few constants and a couple declerations that you need as well.  I will try to list them all here.

'/////// Constants
Public Const MAX_PATH = 260
Public Const ERROR_NO_MORE_FILES = 18&
Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Const INTERNET_FLAG_PASSIVE = &H8000000

'////// Wininet.dll
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hOpen As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As String, lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long
Public Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" (ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long
Public Declare Function FtpOpenFile Lib "wininet.dll" Alias "FtpOpenFileA" (ByVal hFtpSession As Long, ByVal sFileName As String, ByVal lAccess As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, pBuffer As Byte, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer

That should be about all you need.

G
Avatar of Jambyte

ASKER

when it saves the file it uses the clients date to stamp the file with. is there a way i can make it use the server's file date? i uped the points a little cuz this gets tricker
Avatar of Jambyte

ASKER

oops sorry this is the date checking code nevermind... and thank you!