【www.gdgbn.com--文本特效】

asp fso:创建文件 CreateTextFile 实例教程

CreateTextFile方法创建一个新的文本文件在当前文件夹中,并传回TextStream物件,可以用来读取或写入档案。

语法
FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]])
FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
ParameterDescriptionfilenameRequired. The name of the file to createoverwrite任择。一个布尔值,表明是否现有的文件可以被覆盖。真正表明该文件可以覆盖和虚假表明该文件不能被覆盖。预设值是trueunicode任择。一个布尔值,表明是否文件被创建为Unicode或ASCII文件。真指出,档案是创建一个Unicode文件,虚假表明该文件是创建一个ASCII文件。默认值为false
对文件操作教程.
<%
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
%>
对文件夹操作教程.
<%
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
%>

本文来源:http://www.gdgbn.com/wangyetexiao/17356/