FileDateTime Function |
Named Arguments
No
Syntax
FileDateTime(pathname)
pathname
Use: Required
Data Type: String
The filename, along with an optional drive and path.
Return Value
A Variant of subtype Date containing the date and time that the specified file was last modified.
Description
Obtains the date and time a particular file was last modified.
Rules at a Glance
If you don't specify a drive or folder with filename, the file is assumed to be in the current drive or folder.
Programming Tips and Gotchas
Use the Dir function to determine that the file exists before calling File-DateTime. If filename doesn't exist, your application generates runtime error 53, "File not found."
FileDateTime is a read-only: you can retrieve, but you can't set, the file's date and time property.
If a file has not been modified, its creation date and last modified date are identical. However, if the file has been modified since its creation, the File-DateTime function returns only the date last modified. To obtain the file's creation date, you must use the Window's API. The GetFileTime API call returns not only the date last modified, but the file's creation date and last access date as well.
You can also use FileDateTime on hidden files.
The File System object model in VB6 allows you to reference a file using the File object. You can use it to obtain the date a file was created, last accessed, and last modified.
See Also
- ChDir Statement, Dir Statement
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.