Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

ASP OpenTextFile 方法


❮ FileSystemObject 对象完整参考

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

❮ FileSystemObject 对象完整参考
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.