Revision Difference
file.Find#529583
<function name="Find" parent="file" type="libraryfunc">
<description>Returns a list of files and directories inside a single folder.⤶
<bug issue="4867">This function can return weird directories due to VPK file searching. **This is fixed in next update.**</bug>⤶
</description>⤶
<description>Returns a list of files and directories inside a single folder.</description>⤶
<realm>Shared and Menu</realm>
<args>
<arg name="name" type="string">The wildcard to search for. `models/*.mdl` will list **.mdl** files in the `models/` folder.</arg>
<arg name="path" type="string">The path to look for the files and directories in. See <page text="this list">File_Search_Paths</page> for a list of valid paths.</arg>
<arg name="sorting" type="string" default="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.</arg>
</args>
<rets>
<ret name="" type="table">A table of found files, or `nil` if the path is invalid</ret>
<ret name="" type="table">A table of found directories, or `nil` if the path is invalid</ret>
</rets>
</function>
<example>
<description>Prints the first file and the first directory in the `data` folder.</description>
<code>
local files, directories = file.Find( "*", "DATA" )
print( "File: " .. files[1], "Folder: " .. directories[1] )
</code>
<output>
```
File: helloworld.txt
Folder: ctp
```
</output>
</example>