'*************************************
'Reading files
'*************************************
Function loadfromfile (byval file)
Dim objstream
Dim rtext
Rtext = array (0 ,"")
Set objstream = server. Createobject ("ADODB. Stream ")
With objstream
. Type = 2
. Mode = 3
. Open
. Charset = "UTF-8"
. Position = objstream. Size
On Error resume next
. Loadfromfile server. mappath (file)
If err then
Rtext = array (ERR. Number, Err. description)
Loadfromfile = rtext
Err. Clear
Exit Function
End if
Rtext = array (0,. readtext)
. Close
End
Loadfromfile = rtext
Set objstream = nothing
End Function
'*************************************
'Save the file
'*************************************
function savetofile (byval strbody, byval file)
dim objstream
dim rtext
rtext = array (0 ,"")
set objstream = server. createobject ("ADODB. stream ")
with objstream
. type = 2
. open
. charset = "UTF-8"
. position = objstream. size
. writetext = strbody
on error resume next
. savetofile server. mappath (file), 2
If err then
rtext = array (err. number, err. d EIPs)
savetofile = rtext
err. clear
exit function
end if
. close
end with
rtext = array (0, "the file is saved successfully! ")
savetofile = rtext
set objstream = nothing
end function