asp fso:建立檔案 CreateTextFile 執行個體教程
CreateTextFile方法建立一個新的文字檔在當前檔案夾中,並傳回TextStream物件,可以用來讀取或寫入檔案。
文法
FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]])
FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
Parameter |
Description |
filename |
Required. The name of the file to create |
overwrite |
任擇。一個布爾值,表明是否現有的檔案可以被覆蓋。真正表明該檔案可以覆蓋和虛假表明該檔案不能被覆蓋。預設值是true
|
unicode |
任擇。一個布爾值,表明是否檔案被建立為Unicode或ASCII檔案。真指出,檔案是建立一個Unicode檔案,虛假表明該檔案是建立一個ASCII檔案。預設值為false
|
對檔案操作教程.
<%dim fs,tfileset fs=Server.CreateObject("Scripting.FileSystemObject")set tfile=fs.CreateTextFile("c:somefile.txt")tfile.WriteLine("Hello World!")tfile.closeset tfile=nothingset fs=nothing%>
對檔案夾操作教程.
<%dim fs,fo,tfileSet fs=Server.CreateObject("Scripting.FileSystemObject") Set fo=fs.GetFolder("c:test") Set tfile=fo.CreateTextFile("test.txt",false) tfile.WriteLine("Hello World!")tfile.Closeset tfile=nothingset fo=nothingset fs=nothing%>