File.GetDirectories Method

Reads a directory, gets the names of all sub-directories, and returns them in an array of Strings.
<string_array> =File.GetDirectories ( 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 sub-directories within a directory. If the specified directory path does not exist, this method throws an exception. One sub-directory name is returned per array element. The length of the returned String array indicates how many sub-directories were discovered. The sub-directory names are relative to the specified path. If sub-directories are being actively created or deleted when this method is invoked, some existing sub-directories may be missed or a blank String element may be returned.

Examples

Dim files() As String
Dim ii As Integer
files = File.GetDirectories(path)
Console.Writeline(CStr(files.Length) & " directories 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.GetFiles