'读取文件
'*************************************
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
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!