metodo ASP CreateTextFile
Metodo CreateTextFile per creare un nuovo file di testo nella cartella corrente e ritorna può essere utilizzato per leggere o scrivere l'oggetto file TextStream.
grammatica
FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]])
FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
参数 | 描述 |
---|---|
filename | 必需的。需创建文件的名称。 |
overwrite | 可选的。指示能否覆盖已有文件的布尔值。True 指示可覆盖文件,False 指示不能覆盖文件。默认是 True 。 |
unicode | 可选的。指示文件是作为 Unicode 还是 ASCII 文件来创建的布尔值。True 指示文件作为 Unicode 文件创建,False 指示文件作为 ASCII 文件创建。默认是 False。 |
Per esempio oggetto 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
%>
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
%>
Per oggetto Folder esempio
<%
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
%>
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
%>
Completa FileSystemObject Object Reference