返回相應(yīng)于指定路徑中驅(qū)動(dòng)器的 Drive 對(duì)象。
object.GetDrive ( drivespec );
對(duì)于網(wǎng)絡(luò)共享,需要進(jìn)行檢查以確保共享存在。
如果 drivespec 和可接受的形式不一致或是不存在,那么將產(chǎn)生錯(cuò)誤。
要在普通的路徑字符串上調(diào)用 GetDrive 方法,可以使用以下序列來(lái)獲取適于作為 drivespec 的字符串。
[JScript] DriveSpec = GetDriveName(GetAbsolutePathName(Path)) [JScript]
下面的例子說(shuō)明了 GetDrive 方法的用法。
[JScript] function ShowFreeSpace(drvPath) { var fso, d, s =""; fso = new ActiveXObject("Scripting.FileSystemObject"); d =fso.GetDrive(
fso.GetDriveName(drvPath))
; s = "Drive " + drvPath.toUpperCase( ) + " - "; s += d.VolumeName + "<br>"; s += "Free Space: " + d.FreeSpace/1024 + " Kbytes"; return(s); } [VBScript] DriveSpec = GetDriveName(GetAbsolutePathName(Path))
[VBScript]
下列示例說(shuō)明了 GetDrive 方法的用法:
[VBScript] 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 方法 | GetFileVersion 方法 | GetFolder 方法 | GetParentFolderName 方法 | GetSpecialFolder 方法 | GetTempName 方法
應(yīng)用于:FileSystemObject 對(duì)象