object.opentextfile(filename[, iomode[, create[, format]]])
参数
object :必选项。应为 filesystemobject 对象的名称。
filename :必选项。字符串表达式,指明要打开的文件名称。
iomode :可选项。输入/输出模式,是下列三个常数之一:forreading,forwriting,或 forappending。
create :可选项。boolean 值,指出当指定的 filename 不存在时是否能够创建新文件。允许创建新文件时为 true,否则为 false。默认值为 false。
format :可选项。三个 tristate 值之一,指出以何种格式打开文件。若忽略此参数,则文件以 ascii 格式打开。
设置
iomode 参数可为下列设置之一:
常数 值 描述
forreading 1 以只读模式打开文件。不能对此文件进行写操作。
forwriting 2 以只写方式打开文件。不能对此文件进行读操作。
forappending 8 打开文件并在文件末尾进行写操作。
format 参数可为下列设置之一:
常数 值 描述
tristateusedefault -2 以系统默认格式打开文件。
tristatetrue -1 以 unicode 格式打开文件。
tristatefalse 0 以 ascii 格式打开文件。
说明
以下代码举例说明如何使用 opentextfile 方法打开写文件:
sub opentextfiletest
const forreading = 1, forwriting = 2, forappending = 8
dim fso, f
set fso = createobject("scripting.filesystemobject")
set f = fso.opentextfile("c:testfile.txt", forwriting, true)
f.write "嗨,你好!"
f.close
end sub
硕编程写的一个判断文件是否被更改过的代码
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!