如何使用XCDZIP35.OCX对文件压缩

首先注册

 

在窗口中插入ole控件

命名为 ole_zip


//指定需要压缩的具体文件名
ole_zip.object.FilesToProcess =sle_socure.text
//可以指定压缩文件时所采用的密码
//(密码长度可达80个字符,最好设置长一点,不容易被解密)
//ole_zip.object.password ='SunGxf'     //密码(把用户的注册码作为的密码,为注册的使用'SunGxf')
ole_zip.object.UseTempFile=false    //压缩时是否使用临时文件
ole_zip.object.TempPath=''    //压缩时使用临时目录
ole_zip.object.Multidiskmode=TRUE    //是否多盘压缩(分盘)
ole_zip.object.ClearDisks=TRUE    //是否清除磁盘内容
ole_zip.object.UsepATHS=FALSE    //是否保存路径
ole_zip.object.Recurse=FALSE     //是否包括子目录
ole_zip.object.Compression=as_compression     //设置压缩率(0-9)
//指定压缩到什么文件中(如果源文件存在,则同名文件会更新)
ole_zip.object.ZipFilename = sle_dest.text
//开始压缩

REsultCode = ole_zip.object.Add(0)   //开始压缩

If ResultCode <> 0 Then
  Messagebox("提示", "压缩不成功"))
end if

控件下载



附件: [如何使用XCDZIP35.OCX对文件压缩] mJAvbBls.rar (2006-10-18 18:19, 65.06 K)
该附件被下载次数 32


==============================

 

解压缩

 

//解压缩哪些文件,用*表示zip中所有文件
ole_1.object.FilesToProcess = "*"
//指定原来压缩文件时所采用的密码,密码不正确则会激发xceedzip的SkippingFile事件
ole_1.object.Password = ""
ole_1.object.Overwrite=1
//ole_1.object.PreservePaths = true
//指定解压缩到的起始目录
ole_1.object.ExtractDirectory ='D:/ddd'    //D:/XXXX/DATA/01/SJ00001(2001-12-29)
//指定需要解压缩的原zip文件
ole_1.object.ZipFilename ="D:/ddd/a.zip"
//开始列出压缩包中的文件
ResultCode = ole_1.object.list()

//xecAll (0) All the listed files are extracted from the archive, into the destination directory specified by ExtractDirectory.
//xecFreshen (1) Only the listed files to extract from the archive that are more recent than those already existing in the destination directory are extracted. Files that only exist in the archive but not in the destination directory are not extracted.
//xecUpdate (2) Same as xecFreshen, but also extracts files that do not already exist.
//这句话以前没有,忘了加

ole_1.object.extract('0')//参数‘0’,'1','2'你可以试一下,我上传一个帮助你看看,'0',跟'2'的时候可以成功
//检查是否成功
a = ole_1.object.FileCount   //压缩包中的文件数
if ResultCode=0 or  ResultCode=410 then//(带密码的ZIP)
messagebox(string(a),'成功'+string(ResultCode))
end if


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值