Page

B.2.3- The File Object

Created by Brendan Doss.
Last Updated by Brendan Doss.  

PublicCategorized as Appendix B.

Not yet tagged
<< B.2.2- The Folder ObjectAppendixBB.3.0- The Scripting.TextStream Object >>

The File Object

The File object provides access to the files within eachfolder.

 

Property

Description

Attributes

Returns the attributes of the file. Can be a combination of any of the values: Normal (0), ReadOnly (1), Hidden (2), System (4), Volume (name) (8), Directory (folder) (16), Archive (32), Compressed (128) and Alias (1024).

DateCreated

Returns the date and time that the file was created.

DateLastAccessed

Returns the date and time that the file was last accessed.

DateLastModified

Returns the date and time that the file was last modified.

Drive

Returns the drive letter of the drive on which the file resides.

Name

Sets or returns the name of the file.

ParentFolder

Returns the Folder object for the parent folder of this file.

Path

Returns the absolute path of the file using long file names where appropriate.

ShortName

Returns the DOS-style 8.3 version of the file name.

ShortPath

Returns the DOS-style 8.3 version of the absolute path of this file.

 

Property

Description

Size

Returns the size of the file in bytes.

Type

Returns a string that is a description of the file type (such as "Text Document" for a .txt file) if available.

 

Method

Description

Copy(destination,
     
overwrite)

Copies this file to the folder specified in destination. If destination ends with a path separator character ('\') then destination is assumed to be a folder into which the copied file will be placed, otherwise it is assumed to be a full path and name for a new file to be created. An error will occur if the destination file already exists and the optional overwrite parameter is set to False. The default for overwrite is True.

CreateTextFile
     (
filename,
     
overwrite,
     
unicode)

Creates a new text file on disk with the specified filename, and returns a TextStream object that refers to it. If the optional overwrite parameter is set to True, any existing file with the same path and name will be overwritten. The default for overwrite is False. If the optional unicode parameter is set to True, the content of the file will be stored as Unicoded text. The default for unicode is False.

Delete(force)

Deletes this file. If the optional force parameter is set to True the file will be deleted even if the Read-only attribute is set. The default for force is False.

Move(destination)

Moves this file to the folder specified in destination. If destination ends with a path separator character ('\') then destination is assumed to be the folder in which to place the moved file, otherwise it is assumed to be a full path and name for a new file. An error will occur if the destination file already exists.

OpenAsTextStream
    
(iomode,
      format)

Opens a specified file, and returns a TextStream object that can be used to read from, write to, or append to the file. The iomode parameter specifies the type of access required. The permissible values are ForReading (1 – the default), ForWriting (2), and ForAppending (8). The format parameter specifies the format of the data to be read from or written to the file. Permissible values are TristateFalse (0 – default) to open it as ASCII, TristateTrue (-1) to open it as Unicode, and TristateUseDefault (-2) to open it using the system default format.

<< B.2.2- The Folder ObjectAppendixBB.3.0- The Scripting.TextStream Object >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |