Get full access to
VB .NET Language in a Nutshell
and 60K+ other titles, with a free 10-day trial of O'Reilly.
There are also live events, courses curated by job role,
and more.
Start your free trial
Syntax
Directory.GetDirectories(path [, searchpattern])
-
-
Use: Required
Data Type: String
A valid path to a directory
-
searchpattern
-
Use: Optional
Data Type: String
A directory specification, including wildcard characters
Return Value
An array of strings, each element of which is the name of a
subdirectory
Description
Returns the names of the subdirectories in a particular directory
Rules at a Glance
-
path
can be either an absolute path (a
complete path from the root directory to the directory whose
subdirectories are to be retrieved) or a relative path (starting from
the current directory to the directory whose subdirectories are to be
retrieved).
path
can be either a path on the local
system, the path of a mapped network drive, or a UNC path.
path
cannot contain wildcard characters.
-
If
searchpattern
is specified, the method
returns only those directories whose names match the string, which
can contain wildcard characters. Otherwise,
searchpattern
returns the names of all the
subdirectories in the target directory specified by
path
.
-
If the directory specified by
path
has no
subdirectories, or if no directories match
searchpattern
, an empty array is returned.
Example
The following code displays all subdirectories of
c:\
whose names start with the letter P:
Dim sDirs( ) As String
Dim i As Integer
sDirs = Directory.GetDirectories("c:\", "P*")
For i = 0 To UBound(sDirs)
Console.WriteLine(sDirs(i))
Next
Programming Tips and Gotchas ...
Get
VB .NET Language in a Nutshell
now with the O’Reilly
learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and
nearly 200 top publishers.
Start your free trial
Don’t leave
empty-handed
Get Mark Richards’s
Software Architecture Patterns
ebook to better understand how to design components—and how they should interact.
It’s yours, free.
Get it now
Check it out now
on O’Reilly
Dive in for free with a 10-day trial of the O’Reilly learning platform—then explore all the other resources our members count on to build skills and solve problems
every day.
Start your free trial
Become a member now