GetDrive 方法

描述
返回与指定的路径中驱动器相对应的 Drive 对象。
语法
object.GetDrive drivespec

GetDrive 方法的语法有以下部分:

部分 描述
object 必选。应为 FileSystemObject 的名称。
drivespec 必选。drivespec 可以是驱动器号 (c)、带冒号的驱动器号 (c:)、带有冒号与路径分隔符的驱动器号 (c:\) 或任何指定的网络共享 (\\computer2\share1)。

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

如果 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 = s
End Function 



本文档由兄弟工作组制作完成,部分内容摘自因特网公开的文档资料,欢迎您和我们一起完善此文档。兄弟工作组网站: www.vrbrothers.com