Directory.GetLogicalDrives Method


Directory.GetLogicalDrives Method

Class

System.IO.Directory

Syntax

     Dim result(  ) As String = Directory.GetLogicalDrives  (  ) 

Description

The GetLogicalDrives method returns an array of strings, with each element containing the root directory of each logical drive on the local system.

Usage 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 directory \\SomeServer\C\SomeFolder is mapped to the "Z" drive, then GetLogicalDrives will return "Z:\" for this logical drive.

Example

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

Typical output for this code looks like the following:

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

Version Differences

Visual Basic 2005 includes a My.Computer.FileSystem.Drives property that provides similar functionality.




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net