File.GetFiles Method

Reads a directory, gets the names of all non-directory files, and returns them in an array of Strings.

<string_array> =File.GetFiles ( path )

Prerequisites

Directories can only be read on the devices "/ROMDISK", "/flash", and "/GPL".

Parameters

path

A required String expression that contains the path to the directory that is to be read. The path may not specify wild-card file name matching.

Remarks

This method permits a GPL program to retrieve the names of files within a directory. If the specified directory path does not exist, this method throws an exception. One file name is returned per array element. The length of the returned String array indicates how many files were detected. The file names are relative to the specified path. If files are being actively created or deleted when this method is invoked, some existing files may be missed or a blank String element may be returned.

Examples

Dim files() As String
Dim ii As Integer
files = File.GetFiles(path)
Console.Writeline(CStr(files.Length) & " files seen")
For ii = 1 To files.Length
---Console.Writeline("File " & CStr(ii) & ": " & files(ii-1))
Next ii

See Also

File and Serial I/O | File.GetDirectories