Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GET Create Date for a File in a Directory 1

Status
Not open for further replies.

Allwolfpackfan

Programmer
May 9, 2019
21
US
I am trying to obtain the create and/or modified date for a file in a specific directory using FoxPro commands.
"dir G:\Projects\Departments\Sandvik\Export\MCGages.csv to file Timtest" creates a text file with the filename
but does not have any information about the create/modify date. I've tried all the switches with Dir but they
do not work in FoxPro. Any help would be appreciated. My main goal is to check the last time the file was created.
 
Use ADIR(). Something like this:

Code:
LOCAL laFiles
ADIR(laFiles, "G:\Projects\Departments\Sandvik\Export\MCGages.csv")
? laFiles(3)    && Date last modified
? laFiles(4)    && Time last modified



Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,
When it executes the ADIR line it gives an error saying laFiles is not an array. I am using Microsoft Visual FoxPro 6.0.
 
Hi Mike,
I took what you had and modified it slightly to give what I need. Here is the final code I used.

ADIR(laFiles, "G:\Projects\Departments\Sandvik\Export\MCGages.csv")
mdate= laFiles(3) && save date to mdate

Thanks so much for your help.
 
I don't know why you saw that error, but if it is now working, that's fine.

By the way, regarding the DIR command .... DIR by itself does give file dates, but it only works for DBF files. If you use DIR with a filespec (as you did), it simply gives the filenames, as you discovered.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike, that errors because you didn't define laFiles as an array.

In VFP6 do DIMENSION laFILES[1] and ADIR will extend that single element array, but no version of VFP takes a variable not an array. You either don't predefine an array and therefore get an array with PRIVATE variable scope or you predefine an array, for example when you prefer that to be a LOCALly scope array.

Bye, Olaf.





Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top