File date and time
By Sergey - Posted on January 1st, 2008
Code below shows how to retrieve file date and time using native VFP commands or WSH.
For Windows API based solution that also allows to set file date and time, see George Tasker's
Windows Time hosted on http://www.UniversalThread.com.
MSDN links:
WSH FileSystemObject Object
WSH File Object
| This is sample code. Add error handling and adjust to your requirements as necessary. |
&& VFP - Last Modified only #DEFINE ADIR_NAME 1 #DEFINE ADIR_SIZE 2 #DEFINE ADIR_DATE 3 #DEFINE ADIR_TIME 4 #DEFINE ADIR_ATTR 5 lcFileName = "test.txt" DIMENSION laFleInfo[1] = ADIR(laFleInfo, lcFileName) && Date and Time Modified ? laFleInfo[ADIR_DATE], laFleInfo[ADIR_TIME] && Date Modified ? FDATE(lcFileName) && Time Modified ? FTIME(lcFileName) && Date and Time Modified ? FDATE(lcFileName,1) &&----------------------------------------- && WSH && Full path is required lcFileName = FULLPATH("test.txt") loFSO = CREATEOBJECT("Scripting.FileSystemObject") loFile = loFSO.GetFile(lcFileName) ? loFile.DateLastModified, loFile.DateCreated, loFile.DateLastAccessed
Recent comments
11 hours 10 min ago
1 week 23 hours ago
4 weeks 14 hours ago
5 weeks 5 hours ago
5 weeks 5 hours ago
7 weeks 4 days ago
8 weeks 1 day ago
8 weeks 1 day ago
8 weeks 4 days ago
8 weeks 4 days ago