Garry's Mod Wiki

file.Read

string file.Read( string fileName, string path = "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 path = "DATA"
The path used to look up the file.

  • GAME Structured like base folder (garrysmod/), searches all the mounted content (main folder, addons, mounted games etc)
  • LUA or lsv - All Lua folders (lua/) including gamesmodes and addons
  • DATA Data folder (garrysmod/data)
  • MOD Strictly the game folder (garrysmod/), ignores mounting.

It can also be a boolean:

  • true = GAME
  • false = DATA

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!

Page Links


Special Pages


Wikis

?

Render Time: 30ms

DB GetPage 3
Generate Html 4
SaveChanges (1) 9
Render Body 0
Render Sidebar 11