Metoda ASP CreateTextFile
Metoda CreateTextFile w bieżącym folderze, aby utworzyć nowy plik tekstowy i zwraca obiekt TextStream do odczytu i zapisu tego pliku dostarczonego.
gramatyka
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。 |
Dla obiektu wystąpienie pliku
<%
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
%>
Na przykład obiekt 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
%>
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
%>
Kompletna Folder Object Reference