Share via


EnumerateDirectories Method

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

Returns an enumerable collection of directory names in a specified path.

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

Syntax

'Declaration
Public Shared Function EnumerateDirectories ( _
    path As String _
) As IEnumerable
public static IEnumerable EnumerateDirectories(
    string path
)
public:
static IEnumerable^ EnumerateDirectories(
    String^ path
)
static member EnumerateDirectories : 
        path:string -> IEnumerable 
public static function EnumerateDirectories(
    path : String
) : IEnumerable

Parameters

Return Value

Type: System.Collections. . :: . .IEnumerable
An enumerable collection of the full names (including paths) for the directories in the directory specified by path.

Remarks

You can specify relative or absolute path information in the path parameter. Relative path information is interpreted as relative to the current working directory, which you can determine by using the GetCurrentDirectory method. The returned directory names are prefixed with the value you provided in the path parameter. For example, if you provide a relative path in the path parameter, the returned directory names will contain a relative 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.

The returned collection is not cached; each call to the GetEnumerator on the collection will start a new enumeration.

.NET Framework Security

See Also

Reference

Directory Class

System.IO Namespace