|Top Previous Next|
Opens a file or folder.
File.open(path [, flags [, folder]])
If successful, an instance File object; otherwise an integer with an error code.
Use the typeof operator to determine if the result is an object (success) or a number (failure).
The flags argument combines several constants of the File object by + (addition) or | (bitwise OR). First, either openFile, openFolder, or both must be specified. To that, include one of the following:
Finally, openHidden may be optionally included. If the flags argument is omitted, the value openFile | openFolder | openExisting is used.
The close method must be called when operations on the file are complete.
myFile = File.open("data/myFile.dat", File.openFile | File.createAlways);
if (typeof myFile == "object")
myFile.write("Writing text to the file");