Language Reference
Documentation

Language

Objects
Internet Objects

File Class

Has Constructor: NO, Can Create Instance: YES
Can Subclass: YES

The file object represents a file or directory. To obtain a file object you must use the global method GetFile. A File object that represents a directory provides methods to access its child file objects if any.

See Also: Sound,GetFile,Picture,TextInputStream,TextOutputStream

Methods

CopyFileTo
Syntax: CopyFileTo(DestFolder as File)

The file pointed by this file object will be copied to the Directory pointed by the DestFolder object.

MoveFileTo
Syntax: MoveFileTo(DestFolder as File)

The file pointed by this file object will be moved to the Directory pointed by the DestFolder object.

Delete
Syntax: Delete

The file will be deleted. (Really deleted) The current instance of the object will be invalid its exist property will be false (0).

Launch
Syntax: Launch

The file will be opened. If the file is an application or other executable it will be run. If its is some other type of file the operating system will launch the default application and it will be open.

Item
Syntax: Item(index as integer) as File

When the file is a directory the item function will return the file number "index" in the folder. The first file is number 1. If the item is an alias

Child
Syntax: Child(name as string) as File

When the file is a directory the child function will return the file whose name is equal to "name".

OpenAsTextFile
Syntax: OpenAsTextFile() as TextInputStream

Use this function to open a text file. This function will return a TextInputStream. See TextInputStream for more information.

CreateTextFile
Syntax: CreateTextFile() as TextOutputStream

Use this function to create a text file. This function will return a TextOutputStream. See TextOutputStream for more information.

OpenAsSound
Syntax: OpenAsSound() as Sound

Use this function to open a sound file. This function will return a Sound Object. See Sound for more information.

OpenAsPicture
Syntax: OpenAsPicture() as Picture

Use this function to open an image file. This function will return a Picture Object. If QuickTime is installed it will open any image file supported by QuickTime, else in windows you can open BMP files and in MacOS you can open PICT files. See Picture for more information.

OpenAsPNG
Syntax: OpenAsPNG() as Picture

Use this function to open an PNG image file. This function will return a Picture Object. The resulting picture contains the RGB data and alpha (mask) data. See Picture for more information.

CreateAsFolder
Syntax: CreateAsFolder

Use this method to create a folder from the file object. If the folder is created the direcotory property becomes 1.

Properties

Name
Data Type: String

The name of the file or directory.

AbsolutePath
Data Type: String

Path from volume (hard disk). This property is readonly.

Directory
Data Type: Integer

Its value is 1 if the object represents a folder, 0 if not. This property is readonly.

Exists
Data Type: Integer

The value is 1 if this object represents a physical file, 0 if not. This property is readonly.

Alias
Data Type: Integer

The value is 1 if this object is a shortcut to another file, 0 if not. This property is readonly.

Length
Data Type: Integer

The size of file in bytes. This property is readonly

Locked
Data Type: Integer

Its value is 1 if the file is readonly, 0 if not.

MacDirID
Data Type: Integer

The handle to the directory. For toolbox calls (Not implemented)

IsReadable
DataType: Integer

The value 1 indicates that the current user and settings allow read access to the file object. This property is readonly.

IsWritable
Data Type: Integer

The value 1 indicates that the current user and settings allow write access to the file object. This property is readonly.

ModificationDate
Data Type: Date

The date of modification of the file object as a DATE object. This property is readonly.

CreationDate
Data Type: Date

The date of creation of the file object as a DATE object. This property is readonly.

MacCreator
Data Type: String

A string with the four letter creator code. Only available in Macintosh.

MacType
Data Type: String

A string with the four letter type code. Only available in Macintosh.

Visible
Data Type: Integer

A value of 0 makes or indicates that the file is hidden, a value of 1 if visible.

Parent
Data Type: File

The parent folder where this file is at.

Sample Code

dim f as file,s as sound

//Gets the current folder
f = getfile("")

//Opens the sound temp.snd in a folder named Sounds
//in the current folder
f = f.child("Sounds").child("temp.snd")

//Opens the sound and plays it
s = f.OpenAsSound
s.play