Method 1: createtextfile file generation method
Function writetofile (filename, filecontent)
Set FSO = server. Createobject ("scripting. FileSystemObject ")
Set fp = FSO. createtextfile (server. mappath (filename), true)
FP. Write (filecontent)
End Function
Method 2: file generation using ADODB. Stream
Set ccobjstream = server. Createobject ("ADODB. Stream ")
With ccobjstream
. Type = 2
. Mode = 3
. Open
. Charset = "UTF-8"
. Position = ccobjstream. Size
. Writetext
. Savetofile to generate the file path and file name, 2
. Close
End
Createtextfile Method
Creates a specified file and returns a textstream object. This object can be used to read or write the created file.
Object. createtextfile (filename [, overwrite [, Unicode])
Parameters
Object
Required. The name of the FileSystemObject or folder object.
Filename
Required. String expression, indicating the file to be created.
Overwrite
Optional. Boolean indicates whether existing files can be overwritten. If the file can be overwritten, the value is true. If the file cannot be overwritten, the value is false. If this value is omitted, the existing file cannot be overwritten.
Unicode
Optional. Boolean indicates whether to create a file in Unicode or ASCII format. If a file is created in unicode format, the value is true. If a file is created in ASCII format, the value is false. If this part is omitted, an ASCII file is created.