FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Date of the last file change
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Date of the last file change
Posted: Thu Feb 06, 2020 02:07 PM

Hi,

How to find out the date of the last file change ?

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Date of the last file change
Posted: Thu Feb 06, 2020 02:47 PM
Code (fw): Select all Collapse
   cFILE := "C:\INST_NFE\MyProgam.exe"

   aDIR  := DIRECTORY( cFILE )

   dEXE  := aDIR[1] [3]

   dDateVersion := DTOC( dEXE )
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Date of the last file change
Posted: Thu Feb 06, 2020 03:04 PM

Thanks.
And how do I find out the date when the file was created and the date when the file was last opened ?

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Date of the last file change
Posted: Thu Feb 06, 2020 04:59 PM

If I understand correctly ... Create a database and save all the information on system usage in this database. Sorry if that's not it.

Regards.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Date of the last file change
Posted: Thu Feb 06, 2020 08:14 PM
Code (fw): Select all Collapse
   local oFs, oFile, cFile

   oFs   := CreateObject( "Scripting.FileSystemObject" )
   cFile := "c:\fwh\samples\maria01.prg"
   if oFs:FileExists( cFile )
      oFile := oFs:GetFile( cFile )
      ? oFile:DateCreated, oFile:DateLastModified, oFile:DateLastAccessed
   else
      ? cFile + " does not exist"
   endif


https://docs.microsoft.com/en-us/office ... ect-object
Regards



G. N. Rao.

Hyderabad, India
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Date of the last file change
Posted: Fri Feb 07, 2020 05:38 AM

Thanks, Mr.Rao. This is what you need !

Posts: 99
Joined: Thu Jul 12, 2007 02:02 PM
Re: Date of the last file change
Posted: Fri Feb 07, 2020 06:33 AM
Another solution

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()
        LOCAL   dDate
        
        dDate := FCREATEDATE( "C:\TEST.PDF" )
                
        MsgStop( dDate )
RETURN NIL


#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"

HB_FUNC( FCREATEDATE )

{
        HANDLE          hFile  ;
        WIN32_FIND_DATA wfd ;
        SYSTEMTIME      st ;

        hFile = FindFirstFile( hb_parc( 1 ), &wfd ) ; 
        if ( hFile != INVALID_HANDLE_VALUE )  {
                FileTimeToSystemTime( &wfd.ftCreationTime, &st ) ;
        
                FindClose( hFile ) ;
        }   
        else  {
                st.wYear = 0 ;
                st.wMonth = 0 ;
                st.wDay = 0 ;
        }
        
        hb_retd( st.wYear, st.wMonth, st.wDay ) ;
}

#pragma ENDDUMP

regards
Massimo
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Date of the last file change
Posted: Fri Feb 07, 2020 01:01 PM

Please,
the definition of oFile:DateLastAccessed?

How can I try this?
How do I open a file to find that modified parameter?

Many thanks
Marco

Marco Boschi
info@marcoboschi.it
Posts: 99
Joined: Thu Jul 12, 2007 02:02 PM
Re: Date of the last file change
Posted: Fri Feb 07, 2020 02:15 PM
Hi Marco,

I send you an example with LastAccess and LastWrite

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()
        LOCAL   dDate
        
        dDate := FCREATEDATE( "C:\TEST.PDF" )        
                
        MsgStop( dDate )
        
        dDate := FLACCESSDATE( "C:\TEST.PDF" )        
                
        MsgStop( dDate )
        
        dDate := FLWRITEDATE( "C:\TEST.PDF" )        
                
        MsgStop( dDate )
RETURN NIL


#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"

HB_FUNC( FCREATEDATE )

{
        HANDLE          hFile  ;
        WIN32_FIND_DATA wfd ;
        SYSTEMTIME      st ;

        hFile = FindFirstFile( hb_parc( 1 ), &wfd ) ; 
        if ( hFile != INVALID_HANDLE_VALUE )  {
                FileTimeToSystemTime( &wfd.ftCreationTime, &st ) ;
        
                FindClose( hFile ) ;
        }   
        else  {
                st.wYear = 0 ;
                st.wMonth = 0 ;
                st.wDay = 0 ;
        }
        
        hb_retd( st.wYear, st.wMonth, st.wDay ) ;
}

HB_FUNC( FLACCESSDATE )

{
        HANDLE          hFile  ;
        WIN32_FIND_DATA wfd ;
        SYSTEMTIME      st ;

        hFile = FindFirstFile( hb_parc( 1 ), &wfd ) ; 
        if ( hFile != INVALID_HANDLE_VALUE )  {
                FileTimeToSystemTime( &wfd.ftLastAccessTime, &st ) ;
        
                FindClose( hFile ) ;
        }   
        else  {
                st.wYear = 0 ;
                st.wMonth = 0 ;
                st.wDay = 0 ;
        }
        
        hb_retd( st.wYear, st.wMonth, st.wDay ) ;
}


HB_FUNC( FLWRITEDATE )

{
        HANDLE          hFile  ;
        WIN32_FIND_DATA wfd ;
        SYSTEMTIME      st ;

        hFile = FindFirstFile( hb_parc( 1 ), &wfd ) ; 
        if ( hFile != INVALID_HANDLE_VALUE )  {
                FileTimeToSystemTime( &wfd.ftLastWriteTime, &st ) ;
        
                FindClose( hFile ) ;
        }   
        else  {
                st.wYear = 0 ;
                st.wMonth = 0 ;
                st.wDay = 0 ;
        }
        
        hb_retd( st.wYear, st.wMonth, st.wDay ) ;
}

#pragma ENDDUMP


regards
Massimo

Continue the discussion