Garry's Mod Wiki

File:Read

  string File:Read( number length = nil )

Description

Reads the specified amount of chars and returns them as a binary string.

Arguments

1 number length = nil
Reads the specified amount of chars. If not set, will read the entire file.

Returns

1 string data

Example

Adapted from extensions/file.lua

function file.Read( filename, path ) if ( path == true ) then path = "GAME" end if ( path == nil || path == false ) then path = "DATA" end local f = file.Open( filename, "rb", path ) if ( !f ) then return end local str = f:Read( f:Size() ) f:Close() if ( !str ) then str = "" end return str end