所有可用驱动器的只读集合。
可移动媒体的驱动器不需要插入媒体,就可以出现在 Drives 集合中。
[JScript]
下面这个例子说明了如何使用 Drives 属性来获取 Drives 集合以及如何使用 Enumerator 对象来遍历该集合:
[JScript]
function ShowDriveList()
{
var fso, s, n, e, x;
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives
);
s = "";
for (; !e.atEnd(); e.moveNext())
{
x = e.item();
s = s + x.DriveLetter;
s += " - ";
if (x.DriveType == 3)
n = x.ShareName;
else if (x.IsReady)
n = x.VolumeName;
else
n = "[Drive not ready]";
s += n + "<br>";
}
return(s);
}
[VBScript]
下列代码说明了如何获取 Drives 集合,以及如何使用 For Each...Next 语句遍历该集合:
[VBScript]
Function ShowDriveList
Dim fso, d, dc, s, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
n = ""
s = s & d.DriveLetter & " - "
If d.DriveType = Remote Then
n = d.ShareName
ElseIf d.IsReady Then
n = d.VolumeName
End If
s = s & n & "<BR>"
Next
ShowDriveList = s
End Function
Drives 集合没有方法。
Drive 对象 | Drives 属性 | File 对象 | Files 集合 | Folder 对象 | Folders 集合