ASP OpenTextFile 方法

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