O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Directory.GetLogicalDrives Method

Class

System.IO.Directory

Syntax

Directory.GetLogicalDrives(  )

Return Value

An array of strings, each element of which contains the name of the root directory on each logical drive on a system

Description

Retrieves the names of all logical drives and root directories on a system

Rules at a Glance

In the case of a mapped network drive, GetLogicalDrives returns the letter to which the drive is mapped. For instance, if the folder \\Pentium\C\AFolder is mapped to the Z drive, then GetLogicalDrives will return Z:\ for this logical drive.

Example

Dim sDrives(  ) As String
Dim i As Integer
sDrives = Directory.GetLogicalDrives(  )
For i = 0 To UBound(sDrives)
    Console.WriteLine(sDrives(i))
Next

On my system, this code displays the following:

A:\
C:\
D:\
E:\
F:\
G:\

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required