定义和用法
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。
实例
针对 File 对象的例子
<% dim fs,tfile set fs=Server.CreateObject("Scripting.FileSystemObject") set tfile=fs.CreateTextFile("d:\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("d:\test") Set tfile=fo.CreateTextFile("somefile.txt",false)tfile.WriteLine("Hello World!") tfile.Close set tfile=nothing set fo=nothing set fs=nothing %>
【相关推荐】
1. asp fso:创建文件 CreateTextFile 实例教程
php入门到就业线上直播课:查看学习
以上就是分享一篇ASP CreateTextFile 的定义和用法的详细内容,更多请关注php中文网其它相关文章!
前端(VUE)零基础到就业课程:点击学习
自己动手写 PHP MVC 框架:点击学习
![](http://m.sbmmt.com/img/upload/article/000/000/020/633501a29d313483.png)