源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

VBS教程:方法-GetDrive 方法

  • 时间:2021-06-21 01:53 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:VBS教程:方法-GetDrive 方法

GetDrive 方法

返回与指定的路径中驱动器相对应的 [b]Drive[/b] 对象。 [code][i]object.[/i][b]GetDrive[/b][i] drivespec [/i][/code] [h3]参数[/h3]object 必选项。应为 FileSystemObject 的名称。 drivespec 必选项。[b]drivespec[/b] 可以是驱动器号 (c)、带冒号的驱动器号 (c:)、带有冒号与路径分隔符的驱动器号 (c:\) 或任何指定的网络共享 (\\computer2\share1)。 [h3]说明[/h3]对于网络共享,检查并确保该网络共享存在。 若[i]drivespec[/i]与已接受格式不一致或不存在,就会出错。为了在调用 [b]GetDrive[/b] 方法时使用标准路径字符串,使用下列序列得到与 [i]drivespec[/i] 相匹配的字符串:
[code]DriveSpec = GetDriveName(GetAbsolutePathName(Path))[/code]
下面示例说明如何使用 [b]GetDrive[/b] 方法:
[code] Function ShowFreeSpace(drvPath)   Dim fso, d, s  Set fso = CreateObject("Scripting.FileSystemObject")  Set d = [b]fso.GetDrive([/b]fso.GetDriveName(drvPath)[b])[/b]  s = "Drive " & UCase(drvPath) & " - "   s = s & d.VolumeName  & "<BR>"  s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)   s = s & " Kbytes"  ShowFreeSpace = sEnd Function [/code]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部