Export (0) Print
Expand All

FileSystemProxy.GetDirectories Method (String)

Returns a collection of strings representing the path names of subdirectories within a directory.

Namespace:  Microsoft.VisualBasic.MyServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public ReadOnlyCollection<string> GetDirectories(
	string directory
)

Parameters

directory
Type: System.String

Name and path of directory.

Return Value

Type: System.Collections.ObjectModel.ReadOnlyCollection<String>
Read-only collection of the path names of subdirectories within the specified directory..

ExceptionCondition
ArgumentException

The path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\.\).

ArgumentNullException

directory is Nothing or an empty string.

DirectoryNotFoundException

The specified directory does not exist.

IOException

The specified directory points to an existing file.

PathTooLongException

The path exceeds the system-defined maximum length.

NotSupportedException

A file or directory name in the path contains a colon (:) or is in an invalid format.

SecurityException

The user lacks necessary permissions to view the path.

UnauthorizedAccessException

The user lacks necessary permissions.

The following table lists examples of tasks involving the My.Computer.FileSystem.GetDirectories method.

To

See

List subdirectories with a specific pattern

How to: Find Subdirectories with a Specific Pattern in Visual Basic

The following example returns all the directories in the directory structure that contain the word Logs in their names and adds them to ListBox1.

For Each foundDirectory In My.Computer.FileSystem.GetDirectories(
      My.Computer.FileSystem.SpecialDirectories.MyDocuments,
      True, "*Logs*")

    ListBox1.Items.Add(foundDirectory)
Next

This example requires that you have a ListBox named ListBox1 on your form.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft