Process | function | When writing a program today, you need to write a text file again and again, so you write a process function that you want to use.
Code:
Sub write2file (strfile, strcontent, Blnappend)
' Write file
' strfile filename (path), strcontent write content, blnappend append
On Error Resume Next
Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
If Blnappend Then
Set Objwritetext = objFSO.OpenTextFile (strfile,8,true)
Else
Set Objwritetext = objFSO.OpenTextFile (strfile,2,true)
End If
Objwritetext.writeline (strcontent)
Set Objwritetext = Nothing
Set objFSO = Nothing
' Fault tolerant Processing
Select Case ERR
Case 424 Response.Write "The path is not found or the directory does not have write permission."
' Case Else Response.Write Err.Description
Case Else Response.Write ERR
End Select
End Sub
Call Method:
Write2file "C:\dd.ini", "DD", True
Or
Call Write2file ("C:\dd.ini", "DD", True)
Description
1. Automatic creation of documents;
2. Cannot automatically create a table of contents