进行目录和文件操作,以及文本文件读写。
VBS | set fso = Server.CreateObject("Scripting.FileSystemObject") |
JS | fso = new ActiveXObject("Scripting.FileSystemObject") |
属性/方法 | 意义 |
---|---|
Drives | 驱动器对象集合 |
Boolean DriveExists(path) | 检测驱动器 |
Drive GetDrive(path) | 取驱动器,返回 Drive 对象, 失败时报错 path 可为"d:", "d:\", "\\pc\share" |
String GetDriveName(path) | 取驱动器名("c:"), 或者空 "", 不检测盘是否存在 |
Boolean FolderExists(path) | 检测目录是否存在 |
Folder CreateFolder(path) | 建立目录 |
MoveFolder(source,target) | 移动目录 |
CopyFolder(source,target[,overwrite]) | 拷贝目录 |
DeleteFolder(path [,force]) | 删除目录(可用通配符), force 是否删除只读文件 |
Folder GetFolder(path) | 返回目录对象, 失败时报错 |
String GetParentFolderName(path) | 取 path 的父目录名 |
String BuildPath(path,name) | 合成路径 |
Folder GetSpecialFoler(type) | 返回指定目录对象, type=0 windows目录 type=1 system目录 type=2 temporary目录 |
Boolean FileExists(path) | 检测文件是否存在 |
File GetFile(path) | 返回文件对象 |
TextStream CreateTextFile("file",OverWrite) | 建立文件,返回 TextStream 对象 |
TextStream OpenTextFile(filename,imode,create,format) | 打开文件,返回 TextStream 对象 |
CopyFile(source,target[,overwrite]) | 拷贝一个或多个文件 |
MoveFile(path,moveto) | 移动文件 |
DeleteFile(path [,force]) | 删除文件(可用通配符), force 是否删除只读文件 |
GetTempName() | 返回唯一临时文件名 |
TextStream GetStandardStream(type) | 返回标准流 type = StdErr = 2 type = StdOut = 1 type = StdIn = 0 |
String GetFileVersion(path) | 取文件版本号 |
String GetExtensionName(path) | 取扩展名,不含点 |
String GetBaseName(path) | 取主名 |
String GetFileName(path) | 取文件名 |
String GetAbsolutePathName(path) | 返回绝对路径名 |
TextStream OpenTextFile(filename,imode,create,format) |
属性/方法 | 意义 | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
filename | 文件名 | |||||||||
imode | 打开模,ForReading=1, ForWriting=8 | |||||||||
create | 文件不存在时,是否建立 | |||||||||
format | 文件格式:
|
属性/方法 | 意义 |
---|---|
TotalSize | 总字节数 |
FreeSpace / AvailableSpace | 剩余字节数 |
DriveLetter | 盘符("C"、"D") |
DriveType | 磁盘类型。 0 unknown,1 removable,2 fixed,3 remote,4 cdrom,5 ramdisk |
SerialNumber | 序列号(整数值) |
FileSystem | 分区类型("FAT"、"FAT32") |
IsReady | 是否只读 |
ShareName | 共享名 |
VolumeName | 卷标名 |
Path | 路径("C:") |
RootFolder | Folder 对象,根目录 |
属性/方法 | 意义 |
---|---|
SubFolders | Folders 集合 |
Files | 文件对象集合 |
Delete() | 删除目录 |
Name | 名称 |
Path | 路径 |
Size | 包含文件字节数,(不适用于根目录) |
DateCreated | 建立日期 |
DateLastAccessed | 查看日期 |
DateLastModified | 修改日期 |
Copy(path [,overwrite]) | 将目录拷贝到另一个位置 |
TextStream CreateTextFile(name[,overwrite]) | 建立文件 |
Drive | Drive 对象,所在磁盘 |
IsRootFolder | 是否根目录 |
ParentFolder | 父目录对象 |
ShortName / ShortPath | 短文件名格式 |
Type | 类型,"文件夹" |
属性/方法 | 意义 |
---|---|
Folder Add(path) | 建立子目录 |
Count | 数量 |
Item(key) | Folder 对象 |
属性/方法 | 意义 |
---|---|
Path / ShortPath / ShortName | 路径 |
Name | 名称 |
Type | 类型 |
Delete() | 删除 |
Copy(path) | 复制到... |
Move(path) | 移动到... |
Size | 大小 |
DateCreated | 建立日期 |
DateLastAccessed | 查看日期 |
DateLastModified | 修改日期 |
OpenAsTextStream() | 打开 |
Attributes | 属性 |
ParentFolder | 所在目录 |
属性/方法 | 意义 |
---|---|
Write() | 写入数据 |
WriteLine() | 写入数据加换行 |
WriteBlankLines() | 写入几行空行 |
Close() | 关闭 |
Read(long) | 读出数据 |
ReadLine() | 读出一行数据 |
ReadAll() | 读出所有数据 |
Skip(long) | 跳过若干 |
SkipLine() | 跳过一行 |
AtEndOfStream | 是否结束 |
AtEndOfLine | 是否行尾 |
Column | 列号 |
Line | 行号 |