File Object

The File object represents a given file on the local machine or on a network share. This object makes all the properties of that file accessible to your code. The File object's properties and methods are listed in Table 19.3 and Table 19.4, respectively.

Table 19.3. File Object Properties

Property

Description

Attributes*

The operating system attributes for that file. Depending on the specific file attribute, this property could be either read/write or read-only.

DateCreated*

The date the file was created.

DateLastAccessed*

The date a user last accessed the file.

DateLastModified*

The date the file was last modified.

Drive*

The drive letter of the drive that holds the current file.

Name

A string value that contains the name of the file.

ParentFolder*

The name of the folder in which the file resides.

Path

The physical path of the file.

ShortName

The 8.3 format name of the file.

ShortPath

The 8.3 format physical path of the file.

Size

The size in bytes of the current file.

Type

The file's type, as determined using your machine's file associations (if one exists). For example, on a machine with Microsoft Word installed, the file test.doc would have a Type property of "Microsoft Word Document."

Table 19.4. File Object Methods

Method

Description

Copy*

Copies the file from one location to another

Delete*

Deletes the file

Move*

Moves the file from one location to another

OpenAsTextStream*

Opens the file for reading, writing, ...

Get ASP in a Nutshell, 2nd 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.