VDN是一套For PB的互联网组件,PB通过VDN可以实现众多互联网功能,比如:高速连接互联网数据库、系统在线发布和智能升级、文件的上传和下载、即时消息、调用服务器端的.NET函数或者PB函数等。
一、首先到http://www.vesn.net/vdn.aspx下载最新版VDN
.测试中遇到问题可以联系:http://www.vesn.net/about.aspx
二、按照说明文档配置好VDN
三、在PB程序里导入IE运行导入组件\导入组件\PB9\uo_vdncore.sru
四、文件的上传下载分为同步和异步,异步可以显示进度
上传文件:
string ls_file,ls_path
if GetFileOpenName("上传文件",ls_path,ls_file,"*")=0 then return
ChangeDirectory(is_current) //恢复目录
//方式一
//类型设置了custom,指定上传到UpdateTest目录,如果该目录不存在服务器会在FileCache下建立
ifuo_vdn.upfile(ls_path,"custom","UpdateTest") =1 then
showinf("文件上传完毕,地址:"+ uo_vdn.FileUrl +" 存储在服务器的:"+uo_vdn.FilePath)
is_server_file="UpdateTest\"+ uo_vdn.uf_getfileinf(ls_path,"name")
end if
异步上传:
string ls_file,ls_path
if GetFileOpenName("上传文件",ls_path,ls_file,"*")=0 then return
ChangeDirectory(is_current) //恢复目录
//第一个文件
ifuo_vdn.upfile(ls_path,"","custom","AsyncUpdate",true,"one")=1 then
showinf("文件正在上传,操作序号:"+ string(uo_vdn.FileCount))
end if
<p>//第二个文件</p><p>if uo_vdn.upfile(ls_path,"另存的文件.tmp","custom","AsyncUpdate",true,"two")=1 then</p><p> showinf("文件正在上传,操作序号:"+ string(uo_vdn.FileCount))</p><p>end if</p>
下载文件:
string ls_file,ls_path,ls_url
if GetFileSaveName("下载文件",ls_path,ls_file,"jpg","JPEG,*.jpg")=0 then return
ChangeDirectory(is_current) //恢复目录
//下载文件
ls_url="http://www.vesn.net/images/logo.jpg"
if uo_vdn.downfile(ls_url,ls_path,false) =1then
showinf("文件下载完毕 存储在:"+uo_vdn.FilePath)
end if
异步下载文件:
string ls_file,ls_path
if GetFileSaveName("下载文件",ls_path,ls_file,"jpg","JPEG,*.jpg")=0 then return
ChangeDirectory(is_current) //恢复目录
ifuo_vdn.downfile("http://www.vesn.net/images/title.jpg",ls_path,true,"one")=1 then
showinf("文件正在下载,操作序号:"+ string(uo_vdn.FileNo))
end if
//第二个文件
ifuo_vdn.downfile("http://www.vesn.net/images/title.jpg",ls_path+".异步下载的第二个文件.jpg",true,"two") =1 then
showinf("文件正在下载,操作序号:"+ string(uo_vdn.FileNo))
end if

本文介绍如何利用VDN组件在PowerBuilder应用程序中实现文件的同步与异步上传及下载功能。通过设置VDN并导入必要的组件,可以轻松完成文件操作,并显示上传下载进度。

8096

被折叠的 条评论
为什么被折叠?



