Ado|fso|stream yesterday I asked this question, but no one answered the point, and today it's done. Posted out to feel useful friends, hope that other friends do not have to detour.
' Read the contents of the file.
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 ' > Very sorry, your host does not support ADODB.stream, can not 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, Please check if there is a!</font></div> "
Err.Clear
Response.End
End If
. Charset = "GB2312"
. Position = 2
LoadFile =. ReadText
. Close
End With
Set objstream = Nothing
End Function
' Store content to file
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 ' > Very sorry, your host does not support ADODB.stream, can not 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 With
Set objstream = Nothing
End Sub