Garry's Mod Wiki


boolean file.IsDir( string fileName, string gamePath )


Returns whether the given file is a directory 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 fileName
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
true if the given path is a directory or false if it's a file.


Prints if helloworld.txt is a directory.

print( file.IsDir( "helloworld.txt", "DATA" ) )
Output: false


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: 39ms

DB GetPage 6
Generate Html 5
SaveChanges (1) 10
Render Body 0
Render Sidebar 15