Use adodb.stream instead to read text files in FSO

xiaoxiao2021-03-05  21

'Reads 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 "

Unfortunately, your host does not support AdoDB.Stream, you can't use this program "Err.clear response.end end if with objstream .type = 2 .mode = 3 .open .loadFromFile Server.mappath (file) If Err.Number <> 0 Then Response.write "
File " & file & " can not be opened, please check if there is existence! "Err.clear response.end end if .charset =" gb2312 ".position = 2 loadfile = .readtext .close end with set objstream = nothingend function

'Memory contents to a 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 "

Unfortunately, your host does not support AdoDB.Stream, you can't use this program "Err.clear response.end end if with objstream .type = 2 .open .charst =" gb2312 ".position = objstream .Size .writetext = strbody .savetofile server.mappath (file), 2 .close end with set objstream = nothingend subj

转载请注明原文地址:https://www.9cbs.com/read-36419.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.034, SQL: 9