Garry's Mod Wiki

file.Exists

  boolean file.Exists( string name, string gamePath )

Description

Returns a boolean of whether the file or directory exists or not.
If you want to check for a directory, file.IsDir will be faster since it won't check for files.

Arguments

1 string name
The file or directory's name. ( You must include the file extension for files, for example "data.txt" )
2 string gamePath
The path to look for the files and directories in. See this list for a list of valid paths.

Returns

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

Example

Prints whether the data folder exists in the base directory.

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