ASP OpenTextFile 方法

2018-09-17 13:12 更新

ASP OpenTextFile 方法


FileSystemObject 對(duì)象參考手冊(cè) 完整的 FileSystemObject 對(duì)象參考手冊(cè)

OpenTextFile 方法打開(kāi)指定的文件,并返回可用來(lái)訪問(wèn)此文件的 TextStream 對(duì)象。

語(yǔ)法

FileSystemObject.OpenTextFile(fname,mode,create,format)

參數(shù) 描述
fname 必需的。要打開(kāi)的文件的名稱。
mode 可選的。如何打開(kāi)文件。
1=ForReading - 打開(kāi)文件用于讀取數(shù)據(jù)。您無(wú)法向此文件寫(xiě)數(shù)據(jù)。
2=ForWriting - 打開(kāi)文件用于寫(xiě)數(shù)據(jù)。
8=ForAppending - 打開(kāi)文件,并向文件的末尾寫(xiě)數(shù)據(jù)。
create 可選的。設(shè)置如果文件名不存在,是否創(chuàng)建新文件。True 指示可創(chuàng)建新文件,F(xiàn)alse 指示新文件不會(huì)被創(chuàng)建。False 是默認(rèn)的。
format 可選的。文件的格式。
0=TristateFalse - 以 ASCII 打開(kāi)文件。默認(rèn)。
-1=TristateTrue - 以 Unicode 打開(kāi)文件。
-2=TristateUseDefault - 使用系統(tǒng)默認(rèn)格式打開(kāi)文件。

實(shí)例

<%
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
%>


FileSystemObject 對(duì)象參考手冊(cè) 完整的 FileSystemObject 對(duì)象參考手冊(cè)
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)