The File class lets applications write to the server's file system. This is useful for storing information without using a database server, creating log files for debugging, and tracking usage. Also, a directory listing is useful for building a content list of streams or shared objects without using Flash Remoting.
By default, a script can access files and directories only within the application directory of the hosting application. A server administrator can grant access to additional directories by specifying virtual directory mappings for File object paths. This is done in the FileObject tag in the Application.xml file, as shown in the following example:
<FileObject>
<VirtualDirectory>/videos;C:\myvideos</VirtualDirectory>
<VirtualDirectory>/fmsapps;C:\Program Files\fms\applications</VirtualDirectory>
</FileObject>
This example specifies two additional directory mappings in addition to the default application directory. Any path that begins with /videos--for example, /videos/xyz/vacation.flv--maps to c:/myvideos/xyz/vaction.flv. Similarly, /fmsapps/conference maps to c:/Program Files/fms/applications/conference. Any path that does not match a mapping resolves to the default application folder. For example, if c:/myapps/filetest is the application directory, then /streams/hello.flv maps to c:/myapps/filetest/streams/hello.flv.
In addition, the following rules are enforced by the server:
A slash (/) must be used as the path separator. Access is denied if a path contains a backslash (\), or if a dot (.) or two dots (..) is the only string component found between path separators.
For example, if a path using a slash (/) is used to create a File object, the application folder is mapped.
Flash Media Server 2
|
Property |
Description |
|---|---|
|
Read-only; a boolean value indicating whether a file can be appended (true) or not (false). |
|
|
Read-only; A boolean value indicating whether a file can be read (true) or not (false). |
|
|
Read-only; A boolean value indicating whether a file was opened in "create" mode (true) or not (false). This property is undefined for closed files. |
|
|
Read-only; a boolean value indicating whether a file can be written to (true) or not (false). |
|
|
Read-only; a Date object containing the time the file was created. |
|
|
Read-only; a boolean value indicating whether the file or directory exists (true) or not (false). |
|
|
Read-only; a boolean value indicating whether the file is a directory (true) or not (false). |
|
|
Read-only; a boolean value indicating whether the file is a regular data file (true) or not (false). |
|
|
Read-only; a boolean value indicating whether the file has been successfully opened and is still open (true) or not (false). |
|
|
Read-only; a Date object containing the time the file was last modified. |
|
|
Read-only; for a directory, the number of files in the directory, not counting the current directory and parent directory entries; for a file, the number of bytes in the file. |
|
|
Read-only; the mode of an open file. |
|
|
Read-only; a string indicating the name of the file. |
|
|
The current offset in the file. |
|
|
Read-only; a string specifying the type of data or encoding used when a file is opened. |
|
Method |
Description |
|---|---|
|
Closes the file. |
|
|
Copies a file to a different location or copies it to the same location with a different filename. |
|
|
Returns a boolean value indicating whether the file pointer is at the end of file (true) or not (false). |
|
|
Flushes the output buffers of a file. |
|
|
If the file is a directory, lists the files in the directory. |
|
|
Creates a directory. |
|
|
Opens a file so that you can read from it or write to it. |
|
|
Reads the specified number of characters from a file and returns a string. |
|
|
Reads the file after the location of the file pointer and returns an array with an element for each line of the file. |
|
|
Reads the next byte from the file and returns the numeric value of the next byte, or -1 if the operation fails. |
|
|
Reads the next line from the file and returns it as a string. |
|
|
Removes the file or directory pointed to by the File object. |
|
|
Moves or renames a file. |
|
|
Skips a specified number of bytes and returns the new file position. |
|
|
Returns the path to the File object. |
|
|
Writes data to a file. |
|
|
Takes an array as a parameter and calls the File.writeln() method on each element in the array. |
|
|
Writes a byte to a file. |
|
|
Writes data to a file and adds a platform-dependent end-of-line character after outputting the last parameter. |