| 描述 | 语言要素 |
|---|---|
| 存储数据键值、项目对的对象。 | Dictionary 对象 |
| 提供对特定磁盘驱动器或者网络共享的属性的访问。 | Drive 对象 |
| 所有可用驱动器的只读集合。 | Drives 集合 |
| 提供对一个文件的所有属性的访问。 | File 对象 |
| 一个文件夹中所有 File 对象的集合。 | Files 集合 |
| 提供对一个计算机的文件系统的访问。 | FileSystemObject 对象 |
| 提供对一个文件夹的所有属性的访问。 | Folder 对象 |
| 包含在一个 Folder 对象中的所有 Folder 对象的集合。 | Folders 集合 |
| 方便对文件的顺序访问。 | TextStream 对象 |
存储数据键和项目对的对象。
y = new ActiveXObject("Scripting.Dictionary")
Dictionary 对象等价于 PERL 联合数组。项目可以是数据的任何形式,并存储在数组中。每个项目都与一个具有唯一性的键相联。该键用于取得单个项目,并且通常是整数或字符串,但也可以是除数组以外的任何类型。
下面代码演示了如何创建 Dictionary 对象:
var y = new ActiveXObject("Scripting.Dictionary"); y.add ("a", "test"); if (y.Exists("a"))document.write("true");...
Add 方法 (Dictionary) | Exists 方法 | Items 方法 | Keys 方法 | Remove 方法 | RemoveAll 方法
Count 属性 | Item 属性 | Key 属性
FileSystemObject 对象 | TextStream 对象
提供对特定磁盘驱动器或网络共享属性的访问。
下面的代码演示了如何用 Drive 对象访问驱动器属性:
function ShowFreeSpace(drvPath) {var fso, d, s;fso = new ActiveXObject("Scripting.FileSystemObject");d = fso.GetDrive(fso.GetDriveName(drvPath));s = "Drive " + drvPath + " - " ;s += d.VolumeName + "<br>";s += "Free Space: " + d.FreeSpace/1024 + " Kbytes";return(s);}
Drive 对象没有方法。
AvailableSpace 属性 | DriveLetter 属性 | DriveType 属性 | FileSystem 属性 | FreeSpace 属性 | IsReady 属性 | Path 属性 | RootFolder 属性 | SerialNumber 属性 | ShareName 属性 | TotalSize 属性 | VolumeName 属性
Drives 集合 | File 对象 | Files 集合 | Folder 对象 | Folders 集合 | GetDrive 方法
所有可用驱动器的只读集合。
可移动媒体的驱动器不需要插入媒体,就可以出现在 Drives 集合中。
下面这个例子说明了如何使用 Drives 属性来获取 Drives 集合以及如何使用 Enumerator 对象来遍历该集合:
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;elsen = "[Drive not ready]";s += n + "<br>";}return(s);}
Count 属性 | Item 属性
Drive 对象 | Drives 属性 | File 对象 | Files 集合 | Folder 对象 | Folders 集合
提供对文件所有属性的访问。
下面的代码演示了如何获得 File 对象以及如何查看它的一个属性。
function ShowFileInfo(filespec) {var fso, f, s;fso = new ActiveXObject("Scripting.FileSystemObject");f = fso.GetFile(filespec);s = f.DateCreated;return(s);}
Copy 方法 | Delete 方法 | Move 方法 | OpenAsTextStream 方法
Attributes 属性 | DateCreated 属性 | DateLastAccessed 属性 | DateLastModified 属性 | Drive 属性 | Name 属性 | ParentFolder 属性 | Path 属性 | ShortName 属性 | ShortPath 属性 | Size 属性 | Type 属性
Drive 对象 | Drives 集合 | Files 集合 | Folder 对象 | Folders 集合
一个文件夹中所有 File 对象的集合。
下面这个例子说明了如何获得一个 Files 集合以及如何使用 Enumerator 对象和 for 语句来遍历该集合:
function ShowFolderFileList(folderspec) {var fso, f, f1, fc, s;fso = new ActiveXObject("Scripting.FileSystemObject");f = fso.GetFolder(folderspec);fc = new Enumerator(f.files);s = "";for (; !fc.atEnd(); fc.moveNext()){s += fc.item();s += "<br>";}return(s);}
Files 集合没有方法。
Count 属性 | Item 属性
Drive 对象 | Drives 集合 | File 对象 | Folder 对象 | Folders 集合