openFile

Function Server and Client icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online and Offline

Available since Server 1.0.0, Client 1.0.0

Stream openFile(string filePath, [ bool writable = false ])

The openFile function is used to open a handle to a file on the hard drive, fetching a Stream object on success.
The file is opened in binary mode, not text mode.
The initial seek position is 0.
If parameter Writable is bool true, the file is created if it doesn't exist.

Parameters

1) string filePath The path to the file.
2) bool writable Optional, defaults to false. Whether to open the file in writable mode.

Return

Stream A handle to the file stream.

Notes

There aren't any notes for this function.

Examples

Example 1 - JavaScript:

file = openFile("test.txt", true) if (file != null) {

   file.writeString("this is a test")
   file.close()

}


Example 2 - Lua:

file = openFile("test.txt", true) if file ~= nil then

   file:writeString("this is a test")
   file:close()

end

Compatibility

There isn't any compatibility information for this function.

Related

Server Related

        createFile
        fileExists
        loadTextFile
        openFile
        saveTextFile


Client Related

        createFile
        fileExists
        loadTextFile
        openFile
        saveTextFile