所有可用驅(qū)動(dòng)器的只讀集合。
可移動(dòng)媒體的驅(qū)動(dòng)器不需要插入媒體,就可以出現(xiàn)在 Drives 集合中。
[JScript]
下面這個(gè)例子說明了如何使用 Drives 屬性來獲取 Drives 集合以及如何使用 Enumerator 對(duì)象來遍歷該集合:
[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 對(duì)象 | Drives 屬性 | File 對(duì)象 | Files 集合 | Folder 對(duì)象 | Folders 集合