Visual Basic Scripting Edition | 語(yǔ)言參考 |
返回與指定的路徑中驅(qū)動(dòng)器相對(duì)應(yīng)的 Drive 對(duì)象。
object.GetDrive drivespec
object
必選項(xiàng)。應(yīng)為 FileSystemObject 的名稱。
drivespec
必選項(xiàng)。drivespec 可以是驅(qū)動(dòng)器號(hào) (c)、帶冒號(hào)的驅(qū)動(dòng)器號(hào) (c:)、帶有冒號(hào)與路徑分隔符的驅(qū)動(dòng)器號(hào) (c:\) 或任何指定的網(wǎng)絡(luò)共享 (\\computer2\share1)。
對(duì)于網(wǎng)絡(luò)共享,檢查并確保該網(wǎng)絡(luò)共享存在。
若drivespec與已接受格式不一致或不存在,就會(huì)出錯(cuò)。為了在調(diào)用 GetDrive 方法時(shí)使用標(biāo)準(zhǔn)路徑字符串,使用下列序列得到與 drivespec 相匹配的字符串:
DriveSpec = GetDriveName(GetAbsolutePathName(Path))
下面示例說明如何使用 GetDrive 方法:
Function ShowFreeSpace(drvPath)
Dim fso, d, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(fso.GetDriveName(drvPath))
s = "Drive " & UCase(drvPath) & " - "
s = s & d.VolumeName & "<BR>"
s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)
s = s & " Kbytes"
ShowFreeSpace = s
End Function
GetAbsolutePathName 方法 | GetBaseName 方法 | GetDriveName 方法 | GetExtensionName 方法 | GetFile 方法 | GetFileName 方法 | GetFolder 方法 | GetParentFolderName 方法 | GetSpecialFolder 方法 | GetTempName 方法
應(yīng)用于:FileSystemObject 對(duì)象