ASP CreateTextFile 方法
完整的 FileSystemObject 對象參考手冊
CreateTextFile 方法可在當前文件夾中創(chuàng)建新的文本文件,并返回可用于讀或?qū)懳募?TextStream 對象。
語法
FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]])
FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
參數(shù) | 描述 |
filename | 必需的。需創(chuàng)建文件的名稱。 |
overwrite | 可選的。指示能否覆蓋已有文件的布爾值。True 指示可覆蓋文件,F(xiàn)alse 指示不能覆蓋文件。默認是 True 。 |
unicode | 可選的。指示文件是作為 Unicode 還是 ASCII 文件來創(chuàng)建的布爾值。True 指示文件作為 Unicode 文件創(chuàng)建,F(xiàn)alse 指示文件作為 ASCII 文件創(chuàng)建。默認是 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
%>
完整的 FileSystemObject 對象參考手冊
更多建議: