GetDirectories Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets the names of subdirectories (including their paths) in the specified directory.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

public static string[] GetDirectories(
	string path
)

Parameters

path
Type: System..::..String
The path for which an array of subdirectory names is returned.

Return Value

Type: array<System..::..String>[]()[][]
An array of the full names (including paths) of subdirectories in the specified path.

The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient.

If there are no subdirectories, this method returns an empty array.

The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory.

This method is identical to GetDirectories(String, String) with the asterisk (*) specified as the search pattern, so it returns all subdirectories but searches only the top directory.

The names returned by this method are prefixed with the directory information provided in path.

The path parameter is not case-sensitive.

Show: