'*************************************
'读取文件
'*************************************
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 with
loadfromfile = rtext
set objstream = nothing
end function
'*************************************
'保存文件
'*************************************
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.description)
savetofile = rtext
err.clear
exit function
end if
.close
end with
rtext = array(0, "保存文件成功!")
savetofile = rtext
set objstream = nothing
end function
如对本文有疑问,
点击进行留言回复!!
网友评论