Simply paste ASP to create, open, write, and close files. Post a complete post later
Create a file
Set objfso = server. Createobject ("scripting. FileSystemObject") 'defines the component
Objfso. createtextfile (server. mappath ("/newfolder/New. asp") 'create a file
Open the file:
1. opentextfile method of FileSystemObject object
Set objfso = server. Createobject ("scripting. FileSystemObject ")
Set objts = objfso. opentextfile (server. mappath ("a.txt"), 1, true) '1 indicates that after Read-Only 2 is cleared, the light is overwritten and calibrated at the end. If it is true, it is created if it does not exist. The default value is false.
2. openastextstream of the file object
Set objfso = server. Createobject ("scripting. FileSystemObject ")
Set objfile = objfso. GetFile (server. mappath ("a.txt "))
Set objts = objfile. openastextstream (1, true)
Read File Content
N = objts. Read (6)
N = objts. Readline
N = objts. readall
Write files
Objts. Write ("content ")
Objts. writeline ("new row and new content ")
Objts. writeblanklines ("3") 'write three blank rows
Close file
Objts. Close
Set objfso = nothing
Set objts = nothing