ขั้นตอนการตั้งค่า OpenTextFile ของ ASP

การเฉพาะไว้และการใช้งาน

เปิดแฟ้มที่กำหนด และส่งคืนองค์ประกอบ TextStream ที่สามารถใช้เข้าถึงแฟ้มนี้

คำสั่ง

FileSystemObject.OpenTextFile(fname,mode,create,format)
ตัวแปร คำอธิบาย
fname สำคัญ
mode ทางเลือก
  • 1=ForReading - เปิดแฟ้มเพื่ออ่านข้อมูล คุณไม่สามารถเขียนข้อมูลลงแฟ้มนี้
  • 2=ForWriting - เปิดแฟ้มเพื่อเขียนข้อมูล
  • 8=ForAppending - เปิดแฟ้มและเขียนข้อมูลที่ท้ายแฟ้ม
create ทางเลือก
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
%>