手机
当前位置:查字典教程网 >脚本专栏 >vbs >VBS教程:方法-GetDrive 方法
VBS教程:方法-GetDrive 方法
摘要:GetDrive方法返回与指定的路径中驱动器相对应的Drive对象。object.GetDrivedrivespec参数object必选项。...

GetDrive 方法

返回与指定的路径中驱动器相对应的

Drive 对象。

object.

GetDrive drivespec

参数

object

必选项。应为 FileSystemObject 的名称。

drivespec

必选项。

drivespec 可以是驱动器号 (c)、带冒号的驱动器号 (c:)、带有冒号与路径分隔符的驱动器号 (c:) 或任何指定的网络共享 (computer2share1)。

说明

对于网络共享,检查并确保该网络共享存在。

若drivespec与已接受格式不一致或不存在,就会出错。为了在调用

GetDrive 方法时使用标准路径字符串,使用下列序列得到与 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 = sEnd Function

【VBS教程:方法-GetDrive 方法】相关文章:

VBS教程:方法-MoveFile 方法

VBS教程:方法-WriteBlankLines 方法

VBS教程:方法-Raise 方法

VBS教程:方法-GetTempName 方法

VBS教程:方法-Read 方法

VBS教程:方法-GetBaseName 方法

VBS教程:方法-Copy 方法

VBS教程:方法-DriveExists 方法

VBS教程:方法-FolderExists 方法

VBS教程:方法-CreateFolder 方法

精品推荐
分类导航