GetDriveName Method

 

Description

 

Returns a string containing the name of the drive for a specified path.

 

PowerBASIC Syntax

 

METHOD GetDriveName ( _

BYVAL bstrPathSpec AS STRING _

) AS STRING

 

Arguments

 

bstrPathSpec

BSTR. The path specification for the component whose drive name is to be returned.

 

Return Value

 

BSTR. The name of the drive.

 

Remarks

 

The GetDriveName method returns a zero-length string (") if the drive can't be determined. The GetDriveName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

 

Example [PowerBASIC]

 

#INCLUDE "windows.inc"

#INCLUDE "scrrun.inc"

 

DIM fso AS IFileSystem

DIM strName AS STRING

 

' Create an instance of the FileSystemObject

fso = NEWCOM "Scripting.FileSystemObject"

' Get the drive name from a path

strName = fso.GetDriveName(UCODE$("C:\MyFolder\Test.txt"))

 

Valid XHTML 1.0 Transitional