Process functions written to text file (ASP)

Source: Internet
Author: User
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





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.