战剑网络,网站建设,系统开发,程序设计

搜索Top
取得远程文件并保存到本地


搜索关键字:
function getremotefiels(remotepath, localpath, filename)
dim strbody
dim filepath

on error resume next

取得流
strbody = getbody(remotepath)
取得保存的文件名
if right(localpath, 1) <> "\" then localpath = localpath & "\"
filepath = localpath & getfilename(remotepath, filename)
保存文件
if savetofile(strbody, filepath) = true and err.number = 0 then
getremotefiles = true
else
getremotefiles = false
end if

end function

远程获取内容
function getbody(url)
dim retrieval
建立xmlhttp对象
set retrieval = createobject("microsoft.xmlhttp")
with retrieval
.open "get", url, false, "", ""
.send
getbody = .responsebody
end with
set retrieval = nothing
end function

重组文件名
function getfilename(remotepath, filename)
dim arrtmp
dim strfileext
arrtmp = split(remotepath, ".")
strfileext = arrtmp(ubound(arrtmp))
getfilename = filename & "." & strfileext
end function

将流内容保存为文件
function savetofile(stream, filepath)
dim objstream

on error resume next


建立adodb.stream对象,必须要ado 2.5以上版本
set objstream = server.createobject("adodb.stream")
objstream.type = 1 以二进制模式打开
objstream.open
objstream.write stream
objstream.savetofile filepath, 2
objstream.close()
关闭对象,释放资源
set objstream = nothing

if err.number <> 0 then
savetofile = false
else
savetofile = true
end if
end function
%>

[ 打印本页 ] [ 收藏本页 ]

[上一篇]:精妙SQL语句
[下一篇]:用ADODB_Stream代替FSO读取文本文件
 ·用ADODB_Stream代替FSO读取文本文件
 ·javascript格式化数字函数FormatNumber
 ·WAP2.0简介
 ·wap2.0技巧篇
 ·WAP中文提交乱码问题解决办法探讨

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
搜索Top

关于我们 - 联系我们 - 广告业务 - 友情链接 - 网站制作 - 留言板 - 会员注册
All Right Zjm.Net.Cn (zjm Enterprise v3.0)
联系电话:0576-8603312 地址:浙江省台州市经济开发区
技术支持:点击这里给我发消息280610248 业务: 点击这里给我发消息40520767 客服: 点击这里给我发消息441758646
E-mail:zjm@zjm.net.cn 备案证书号:浙ICP备06030047号