加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP CreateTextFile 方法介绍

发布时间:2023-10-14 15:04:59 所属栏目:Asp教程 来源:
导读:CreateTextFile 方法可在当前文件夹中创建新的文本文件,并返回可用于读或写文件的 TextStream 对象。

语法

FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]])

FolderObject.CreateText
CreateTextFile 方法可在当前文件夹中创建新的文本文件,并返回可用于读或写文件的 TextStream 对象。
 
语法
 
FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]])
 
FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
 
参数 描述
 
filename 必需的。需创建文件的名称。
 
overwrite 可选的。指示能否覆盖已有文件的布尔值。True 指示可覆盖文件,False 指示不能覆盖文件。默认是 True 。
 
unicode 可选的。指示文件是作为 Unicode 还是 ASCII 文件来创建的布尔值。True 指示文件作为 Unicode 文件创建,False 指示文件作为 ASCII 文件创建。默认是 False。
 
针对 FileSystemObject 对象的实例
 
<%
 
dim fs,tfile
 
set fs=Server.CreateObject("Scripting.FileSystemObject")
 
set tfile=fs.CreateTextFile("c:\somefile.txt")
 
tfile.WriteLine("Hello World!")
 
tfile.close
 
set tfile=nothing
 
set fs=nothing
 
%>
 
针对 Folder 对象的实例
 
<%
 
dim fs,fo,tfile
 
Set fs=Server.CreateObject("Scripting.FileSystemObject")
 
Set fo=fs.GetFolder("c:\test")
 
Set tfile=fo.CreateTextFile("test.txt",false)
 
tfile.WriteLine("Hello World!")
 
tfile.Close
 
set tfile=nothing
 
set fo=nothing
 
set fs=nothing
 
%>
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章