Share via


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)

Syntax

'Declaration
Public Shared Function GetDirectories ( _
    path As String _
) As String()
public static string[] GetDirectories(
    string path
)
public:
static array<String^>^ GetDirectories(
    String^ path
)
static member GetDirectories : 
        path:string -> string[] 
public static function GetDirectories(
    path : String
) : String[]

Parameters

Return Value

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

Remarks

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.

.NET Framework Security

See Also

Reference

Directory Class

System.IO Namespace