ASP OpenAsTextStream Method
Complete File Object Reference Manual
The OpenAsTextStream method opens a specified file and returns a TextStream object for accessing the file.
Syntax
FileObject.OpenAsTextStream(mode,format)
| Parameters | Description |
|---|---|
| mode | Optional. How to open the file (input/output mode).
|
- 0 = TristateFalse - Default. Opens the file in ASCII format.
- -1 = TristateTrue - Opens the file in Unicode format.
- -2 = TristateUseDefault - Opens the file using the system default format.
Example
<%
dim fs,f,ts
set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile("c:\test.txt")
Set ts=f.OpenAsTextStream(ForWriting)
ts.Write("Hello World!")
ts.Close
Set ts=f.OpenAsTextStream(ForReading)
Response.Write(ts.ReadAll)
ts.Close
set ts=nothing
set f=nothing
set fs=nothing
%>
Output:
Hello World!
Complete File Object Reference Manual