file.Find

From Garry's Mod
Jump to: navigation, search
 file.Find( )

Contents

Description

Returns a list of files and directories inside a single folder.

Arguments

string name

The wildcard to search for. "models/*.mdl" will list .mdl files in the models/ folder.

Arguments

string path

The path to look for the files and directories in. See this list for a list of valid paths.

Arguments

string sorting="nameasc"

The sorting to be used, optional.

  • "nameasc" sort the files ascending by name
  • "namedesc" sort the files descending by name
  • "dateasc" sort the files ascending by date
  • "datedesc" sort the files descending by date

Returns

table

A table of found files

Returns

table

A table of found directories

Examples

Example

Prints the first file and the first directory in the data folder.

local files, directories = file.Find("*", "DATA")

print( "File: " .. files[1], "Folder: " .. directories[1] )

Output:


File: helloworld.txt
Folder: ctp
Personal tools
Navigation