ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods







METHOD:  FileSystemObject.OpenTextFile

object.OpenTextFile (filename [, iomode[, create[, format]]])

This method is used to create a text file and returns a TextStreamObject that can then be used to write to and read from the file.

The optional overwrite parameter returns a Boolean value - True (the default) permits overwriting of existing files while False does not. The other optional parameter, unicode, is also a Boolean. In this case, True creates a Unicode file and False (the default) creates an AscII file.

Code:
<%
dim filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\somefile.txt", True)
path = filesys.GetAbsolutePathName("c:\somefile.txt")
getname = filesys.GetFileName(path)
filetxt.WriteLine("Your text goes here.")
filetxt.Close
If filesys.FileExists(path) Then
   Response.Write ("Your file, '" & getname & "', has been created.")
End If
%>

Output:
"Your file, 'somefile.txt', has been created."