วิธี การ ASP OpenAsTextStream
❮ การอ้างอิงออบเจกต์ไฟล์ที่สมบูรณ์
เมธอด OpenAsTextStream จะเปิดไฟล์ที่ระบุและส่งคืนอ็อบเจ็กต์ TextStream เพื่อเข้าถึงไฟล์
ไวยากรณ์
FileObject.OpenAsTextStream(mode,format)
Parameter | Description |
---|---|
mode | Optional. How to open the file.
|
format | Optional. The format of the file.
|
ตัวอย่าง
<%
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!
❮ การอ้างอิงออบเจกต์ไฟล์ที่สมบูรณ์