Finding date of a file in runtime

I'm using PB 7.0 and would like to know how to find out the date and time of a file (*.txt/*.pbd) during runtime.  URGENT!!

Thank you,
Baskar
baskarAsked:
Who is Participating?
 
Miguel_AngelConnect With a Mentor Commented:
If you have worked with API's before you wouldn't find any problems with that.

You need to use 2 API's:

BOOL GetFileTime(
  HANDLE hFile,                 // handle to file
  LPFILETIME lpCreationTime,    // creation time
  LPFILETIME lpLastAccessTime,  // last access time
  LPFILETIME lpLastWriteTime    // last write time
);

BOOL FileTimeToSystemTime(
  CONST FILETIME *lpFileTime,  // file time to convert
  LPSYSTEMTIME lpSystemTime    // receives system time
);
       
And for working with them you need this previus created structures:

st_filetime
     long v_lowdatetime
     long v_highdatetime
       
st_systemtime
     int v_year
     int v_month
     int v_dayofweek
     int v_day
     int v_hour
     int v_minute
     int v_second
     int v_millisecond
       
And the script would look like:

string filename
long   fileid

st_filetime   creationtime, lastaccesstime, lastwritetime
st_systemtime systemtime

filename = "c:\testfile.txt"
fileid   = fileopen(filename)

getfiletime(fileid, creationtime, lastaccesstime, lastwritetime)

filetimetosystemtime(creationtime, systemtime)

And voila, you have in systemtime.v_year, systemtime.v_month, and so on. Of course several error filters should help too, but this isbasically what you need to know.

Good luck.
0
 
baskarAuthor Commented:
pls mail to baskar@comline.com.my
0
 
BhattiCommented:
If you saved your  *.txt file as "tab Separated"  file. Make a datastore from this file and you can access any time to your datastore.  (ImportFile function for *.Txt file). The count of your datastore columns must be equal to the *.txt file columns.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
baskarAuthor Commented:
Hi Bhatti,

No I won't be reading the file, I mean the contents. I just wants to know the last edited date and time of the file.
0
 
baskarAuthor Commented:
Hi Bhatti,

No I won't be reading the file, I mean the contents. I just wants to know the last edited date and time of the file.
0
 
BhattiCommented:
Try with API/SDK functions to find data and time of file attributes.
0
 
baskarAuthor Commented:
Thank you very much for your guidance. Sorry for the delay in getting back.
0
All Courses

From novice to tech pro — start learning today.