'File content reading.
CopyCode The Code is as follows: function LoadFile (byval file)
Dim objstream
On Error resume next
Set objstream = server. Createobject ("ADODB. Stream ")
If err. Number =-2147221005 then
Response. Write "<Div align = 'center'> sorry, your host does not support ADODB. Stream and cannot use this Program </Div>"
Err. Clear
Response. End
End if
With objstream
. Type = 2
. Mode = 3
. Open
. Loadfromfile server. mappath (file)
If err. Number <> 0 then
Response. Write "<Div align = 'center'> file <font color = '# ff0000'>" & file & "</font> cannot be opened. Check whether the file exists! </Font> </div>"
Err. Clear
Response. End
End if
. Charset = "gb2312"
. Position = 2
LoadFile =. readtext
. Close
End
Set objstream = nothing
End Function
'Store content to a fileCopy codeThe Code is as follows: Sub savetofile (byval strbody, byval file)
Dim objstream
On Error resume next
Set objstream = server. Createobject ("ADODB. Stream ")
If err. Number =-2147221005 then
Response. Write "<Div align = 'center'> sorry, your host does not support ADODB. Stream and cannot use this program </div>"
Err. Clear
Response. End
End if
With objstream
. Type = 2
. Open
. Charset = "gb2312"
. Position = objstream. Size
. Writetext = strbody
. Savetofile server. mappath (file), 2
. Close
End
Set objstream = nothing
End sub
Call exampleCopy codeThe Code is as follows: <%
Writefile "aaa.txt", "www.jb51.net", "UTF-8"
Response. Write readfile ("aaa.txt", "UTF-8 ")
%>