Directory.GetDirectoryRoot Method


Directory.GetDirectoryRoot Method

Class

System.IO.Directory

Syntax

     Dim result As String = Directory.GetDirectoryRoot(path) 


path (required; String)

A valid path to a directory

Description

The GetDirectoryRoot method returns the name of the root directory of the drive on which path resides. For example, the code:

     Directory.GetDirectoryRoot("c:\Program Files\MyCompany") 

returns the string "C:\" as the root directory.

Usage at a Glance

  • path can be either an absolute path or a relative path from the current directory.

  • path can be either a path on the local system, the path of a mapped network drive, or a UNC path. For example, the code:

         Directory.GetDirectoryRoot("\\SomeServer\C\SomeFolder") 

    returns "\\SomeServer\C," and if the directory \\SomeServer\C\SomeFolder maps to the local "Z" drive, then:

     Directory.GetDirectoryRoot("Z:\temp") 

    returns Z:\.

  • path cannot contain wildcard characters.

Version Differences

Visual Basic 2005 includes a My.Computer.FileSystem.GetDirectoryInfo method that provides access to detailed information about a directory.

See Also

Directory.GetParent Method




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