Properties of the File Object

The File object allows you to access all of the properties of a specified file. The following lines of code create a reference to the File object:

Set fs = CreateObject("Scripting.FileSystemObject") Set objFile = fs.GetFile("C:\My Documents\myFile.doc")

You will find an example of using the File object in the FileInfo procedure that was created earlier in this chapter. Table 8-4: Selected properties of the File object

Property

Description

Attributes

DateCreated

DateLastAccessed

DateLastModified

Drive

Name

ParentFolder

Path

Size

Type

Returns file attributes (compare this property to the GetAttr VBA function explained at the beginning of this chapter)

File creation date

File last-access date

File last-modified date

Drive name followed by a colon

The name of the file

The parent folder of the file

The full path of the file

File size in bytes (compare this property to the FileLen VBA function explained at the beginning of this chapter)

File type. This is the text that appears in the Type column in the Windows Explorer (e.g., Configuration settings, Application, shortcut)

0 0

Post a comment