Name

FileDateTime Function

Class

Microsoft.VisualBasic.FileSystem

Syntax

FileDateTime(pathname)
pathname (required; String)

The filename, along with an optional drive and path

Return Value

A Date containing the date and time at which the specified file was created or last modified (whichever is later)

Description

Obtains the date and time at which a particular file was created or last modified (whichever is later)

Rules at a Glance

If you don’t specify a drive or folder with pathname, the file is assumed to be in the current drive or folder.

Programming Tips and Gotchas

  • Use the File.Exists method (in the System.IO namespace) to determine that the file exists before calling FileDateTime. If pathname does not exist, your application generates runtime error 53, “File not found.”

  • If a file has not been modified, its creation date and last modified date will be identical. However, if the file has been modified since its creation, the FileDateTime function returns only the last modified date. To obtain the file’s creation date, you have to resort to using 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.

Get VB.NET Language in a Nutshell, Second Edition 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.