Garry's Mod Wiki


boolean file.Exists( string name, string gamePath )


Returns a boolean of whether the file or directory exists or not.

This will sometimes return false clientside for directories received from the server via a clientside lua file. You can work around this by using file.Find with the path to the directory followed by a wildcard (no trailing forward slash) and see if the directory is inside the returned directories table (see second example).

Issue Tracker: 1038


1 string name
The file or directory's name.
2 string gamePath
The path to look for the files and directories in. See this list for a list of valid paths.


1 boolean
Returns true if the file exists and false if it does not.


Prints whether the data folder exists in the base directory.

print( file.Exists( "data", "GAME" ) )
Output: true


Workaround for issue #1038.

local _, dirs = file.Find( "path/to/dir*", "LUA" ) if dirs ~= nil and table.HasValue( dirs, "dir" ) then print( "Directory found!" ) end

Page Links

Special Pages



Render Time: 85ms

DB GetPage 52
Generate Html 11
SaveChanges (1) 8
Render Body 0
Render Sidebar 11