How to get Date and Time with oFTP

John
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

How to get Date and Time with oFTP

Post by John »

Hi,

i'm using oFTP:Directory("*.*"), but it seems it only returns the name and file size. Is there any way to also retrieve the file's date and time?

Thanks,

John.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

John,

Please modify Class TFtp Method Directory this way:

Code: Select all

...
      if ! Empty( oWin32FindData:cFileName )
         AAdd( aFiles, { oWin32FindData:cFileName,;
                         oWin32FindData:nSizeLow,;
                         oWin32FindData:nLastWriteAccess,;
                         oWin32FindData:nCreationTime } )
         while InternetFindNextFile( hFTPDir, @cBuffer )
            oWin32FindData:cBuffer = cBuffer
            AAdd( aFiles, { oWin32FindData:cFileName,;
                            oWin32FindData:nSizeLow,;
                            oWin32FindData:nLastWriteAccess,;
                            oWin32FindData:nCreationTime } )
         end
      endif
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
John
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Post by John »

Hi Antonio,

thanks for the reply. It seems i only get the time returned in this case?

Regards,

John.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

John,

What value do you get for oWin32FindData:nLastWriteAccess ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
John
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Post by John »

Hi Antonio,

i probably did something wrong because i get only empty strings returned for the date and time:

aFtpList:=oFTP:Directory("*.*")
ShowArr(aFtpList)

Function ShowArr(aDirList)
aEval(aDirList,{|i,t| iif(Valtype(i)=="A",(ShowArr(i)),(msgalert(i)) ) })
Return (.t.)

Any suggestions?

Regards,

John.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

John,

Please try this:

aFtpList:=oFTP:Directory("*.*")
MsgInfo( Len( aFtpList[ 1 ][ 3 ] ) )

and let me know what you get, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
John
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Post by John »

Antonio,

it returns an 8, but i can't relate that to a file present...

Regards,

John.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

John,

It looks like there is something different from a number there.
Please try this:

Code: Select all

aFtpList:=oFTP:Directory("*.*") 
for n = 1 to Len( aFtpList[ 1 ][ 3 ] )
   MsgInfo( Asc( SubStr( aFtpList[ 1 ][ 3 ], n, 1 ) ) )
next
and let me know what you get, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
John
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Post by John »

Hi Antonio,

the following files are present in the ftp directory:
Image

I get the following results:
0, 46, 46, 201, 78, 240, 198, 1

Best regards,

John.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

John,

Please copy here the values that you get for each of the four items that you have in the directory, thanks.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

John,

Code: Select all

aFtpList:=oFTP:Directory("*.*")
for m = 1 to Len( aFtpList )
   for n = 1 to Len( aFtpList[ m ][ 3 ] )
      MsgInfo( Asc( SubStr( aFtpList[ m ][ 3 ], n, 1 ) ) )
   next
next
so we can see the eight bytes for each file.
regards, saludos

Antonio Linares
www.fivetechsoft.com
John
Posts: 67
Joined: Mon Dec 26, 2005 7:44 am
Location: The Netherlands

Post by John »

Antonio,

the values are:
0, 46, 46, 201, 78, 240, 198, 1, 0, 232, 33, 111, 190, 255, 198, 1, 0, 46, 46, 201, 78, 240, 198, 1, 0, 46, 46, 201, 78, 240, 198, 1.

Saludos,

John.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

John,

It looks as three files have the same date:

0, 46, 46, 201, 78, 240, 198, 1
0, 46, 46, 201, 78, 240, 198, 1
0, 46, 46, 201, 78, 240, 198, 1
0, 232, 33, 111, 190, 255, 198, 1

From the image that you provided, three have the same date too:

15-10-2006
15-10-2006
15-10-2006
4-11-2006

Now we need to find in what data format the dates are stored.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601.

typedef struct _FILETIME { // ft
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;

Lets see how to get a Clipper date and time from that :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

This is the API function to use:

The FileTimeToSystemTime function converts a 64-bit file time to system time format.

BOOL FileTimeToSystemTime(

CONST FILETIME *lpFileTime, // pointer to file time to convert
LPSYSTEMTIME lpSystemTime // pointer to structure to receive system time
);
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply