ActiveXObject对象的OpenTextFile方法介绍
2012-05-22 17:25
447 查看
OpenTextFile方法打开一个指定的文件并返回一个TextStream对象以用来访问这个文件。
一、语法
FileSystemObject.OpenTextFile(fname,mode,create,format)
参数说明:
fname:必须的。要打开的文件的名字。
mode:可选的。以什么方式打开。1=ForReading(以只读方式打开),2=ForWriting (以写方式打开),8=ForAppending(以添加方式打开,写入的内容将添加到文件末尾)。
create:可选的。设置如果所打开的文件不存在是否创建该文件。True为是,False为否。默认是False。
format:可选的。文件的格式。0=TristateFalse(以ASCII格式打开,这是默认的),-1=TristateTrue(以Unicode格式打开),-2=TristateUseDefault (以系统默认方式打开)
二、例子
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
%>
Property
属性 Description
描述
Attributes
Sets or returns the attributes of a specified file
设置或返回指定文件的属性
DateCreated
Returns the date and time when a specified file was created
返回指定文件建立的日期和时间
DateLastAccessed
Returns the date and time when a specified file was last accessed
返回指定文件最后被访问的日期和时间
DateLastModified
Returns the date and time when a specified file was last modified
返回指定文件最后被修改的日期和时间
Drive
Returns the drive letter of the drive where a specified file or folder resides
返回指定文件或文件夹所处的盘符的盘符号
Name
Sets or returns the name of a specified file
设置或返回指定文件的名字
ParentFolder
Returns the folder object for the parent of the specified file
返回指定文件的父文件夹
Path
Returns the path for a specified file
返回一个指定文件的路径
ShortName
Returns the short name of a specified file (the 8.3 naming convention)
返回一个指定文件的短名 (根据8.3 命名规则)
ShortPath
Returns the short path of a specified file (the 8.3 naming convention)
返回一个指定文件的短路径 (根据8.3 命名规则)
Size
Returns the size, in bytes, of a specified file
返回指定文件所包含的字节数
Type
Returns the type of a specified file
返回指定文件的类型
Methods
方法
Method
方法 Description
描述
Copy
Copies a specified file from one location to another
将本机上的文件复制到异地机子上
Delete Deletes a specified file
删除指定文件
Move
Moves a specified file from one location to another
将本机上的文件移动到异地机子上
OpenAsTextStream
Opens a specified file and returns a TextStream object to access the file
打开指定文件返回一个TextStream对象
一、语法
FileSystemObject.OpenTextFile(fname,mode,create,format)
参数说明:
fname:必须的。要打开的文件的名字。
mode:可选的。以什么方式打开。1=ForReading(以只读方式打开),2=ForWriting (以写方式打开),8=ForAppending(以添加方式打开,写入的内容将添加到文件末尾)。
create:可选的。设置如果所打开的文件不存在是否创建该文件。True为是,False为否。默认是False。
format:可选的。文件的格式。0=TristateFalse(以ASCII格式打开,这是默认的),-1=TristateTrue(以Unicode格式打开),-2=TristateUseDefault (以系统默认方式打开)
二、例子
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
%>
Property
属性 Description
描述
Attributes
Sets or returns the attributes of a specified file
设置或返回指定文件的属性
DateCreated
Returns the date and time when a specified file was created
返回指定文件建立的日期和时间
DateLastAccessed
Returns the date and time when a specified file was last accessed
返回指定文件最后被访问的日期和时间
DateLastModified
Returns the date and time when a specified file was last modified
返回指定文件最后被修改的日期和时间
Drive
Returns the drive letter of the drive where a specified file or folder resides
返回指定文件或文件夹所处的盘符的盘符号
Name
Sets or returns the name of a specified file
设置或返回指定文件的名字
ParentFolder
Returns the folder object for the parent of the specified file
返回指定文件的父文件夹
Path
Returns the path for a specified file
返回一个指定文件的路径
ShortName
Returns the short name of a specified file (the 8.3 naming convention)
返回一个指定文件的短名 (根据8.3 命名规则)
ShortPath
Returns the short path of a specified file (the 8.3 naming convention)
返回一个指定文件的短路径 (根据8.3 命名规则)
Size
Returns the size, in bytes, of a specified file
返回指定文件所包含的字节数
Type
Returns the type of a specified file
返回指定文件的类型
Methods
方法
Method
方法 Description
描述
Copy
Copies a specified file from one location to another
将本机上的文件复制到异地机子上
Delete Deletes a specified file
删除指定文件
Move
Moves a specified file from one location to another
将本机上的文件移动到异地机子上
OpenAsTextStream
Opens a specified file and returns a TextStream object to access the file
打开指定文件返回一个TextStream对象
相关文章推荐
- javascript ActiveXObject FileSystemObject 对象,创建、复制、删除、读取文件等
- ActiveX 部件不能创建对象: 'scripting.filesystemobject'
- error while loading shared libraries: libevent-1.3.so.1:cannot open shared object file :No such file or directory解决方法
- RAC srvctl 命令报 libpthread.so.0 cannot open shared object file No such file or directory 解决方法
- html5的FormData对象和input的file属性以及window.URL.createObjectURL( ) 方法(转载)
- 安装oracle 10g遇到cannot open shared object file这个错误以及解决方法
- Python 用file 对象和open方法处理文件的区别
- 适用于Firemonkey的Json解析对象XsuperObject使用方法介绍
- 安装libmad、libjpeg库时出现:libpng15.so.15 或 libjpeg : cannot open shared object file的解决方法
- error while loading shared libraries: libnet.so.9: cannot open shared object file: No such **解决方法
- ajax利用html5新特性带进度条上传文件 html5的FormData对象和input的file属性以及window.URL.createObjectURL( ) 方法
- 安装oracle 10g遇到cannot open shared object file这个错误以及解决方法
- javascript的window.ActiveXObject对象,区别浏览器的方法
- html5的FormData对象和input的file属性以及window.URL.createObjectURL( ) 方法
- javascript的window.ActiveXObject对象,区别浏览器的方法
- RAC srvctl 命令报 libpthread.so.0 cannot open shared object file No such file or directory 解决方法
- ActiveX 部件不能创建对象: 'Scripting.FileSystemObject'
- linux 中添加自己的库路径的方法 cannot open shared object file: No such file or directory
- libpthread.so.0: cannot open shared object file解决方法
- RAC srvctl 命令报 libpthread.so.0 cannot open shared object file No such file or directory 解决方法