Garry's Mod Wiki

Garry's Mod Wiki

  string file.Read( string fileName, string gamePath = "GAME or DATA" )

Description

Returns the content of a file.

Beware of casing -- some filesystems are case-sensitive. SRCDS on Linux seems to force file/directory creation to lowercase, but will not modify read operations.

Arguments

1 string fileName
The name of the file.
2 string gamePath = "GAME or DATA"
The path to look for the files and directories in. If this argument is set to true then the path will be GAME, otherwise if the argument is false or nil then the path will be DATA. See this list for a list of valid paths.

Returns

1 string
The data from the file as a string, or nil if the file isn't found.

Example

Prints out the content of helloworld.txt.

print( file.Read( "helloworld.txt", "DATA" ) )
Output:
This is the content!

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...