file.Read

From GMod Wiki

Revision as of 16:49, 15 October 2011 by TheFreeman193 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax file.Read( String filepath, [ Boolean usebasefolder ] )
Where is this used?
Description:
Returns the contents of a file as a string. Returns nil if the file does not exist.
Returns: String
Part of Library: File
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=File.Read]File.Read [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Info 64.png You may only Read files rooted from the gmod base folder. 'garrysmod/garrysmod/...'

Examples

DescriptionThis example prints the content of the my_mod/data.txt file to the console
Used onNewerShared.png
Code
local contents = file.Read("my_mod/data.txt")
Msg( contents )
OutputN/A


DescriptionReads one of the stock vmt files and prints it into your console
Used onNewerShared.png
Code
print( file.Read("materials/vgui/sandbox.vmt", true) )
OutputThe contents of sandbox.vmt in your console.
File.Read1.jpg


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox