您的位置:首页 > 移动开发 > Objective-C

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对象
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐