当前注册人数422581人 邮箱: 密码: 注册新用户 忘记密码
首页 C/C++/MFC C# ASP.NET VB.NET MATLAB Android   站内搜索 下载代码说明/积分规则
为什么要注册?

1. 可以直接免费从本站下载代码,防止邮件发送不到您的邮箱,或登录不了国外网站

2. 可以设定关键字,当有您关心的代码收录时,邮件通知您

3. 对这里的代码进行评分和评论

4. 可以和大家一起分享你的源代码,得到更多的建议

using ZipPackage to ZIP files

VB.NET使用ZipPackage实现ZIP文件压缩解压缩示例

2008年08月31日
VB (VB 9.0, VB), Windows (Windows, WinXP, Vista), Visual Studio (VS2008, Visual Studio), Dev
作为.net库中System.IO.Packaging空间的ZipPackage类的一个实例,展示如何向winrar那样压缩解压缩文件。
相关知识

    Private Sub AddToArchive(ByVal zip As Package, _ 
                         ByVal fileToAdd As String)

        'Replace spaces with an underscore (_) 
        Dim uriFileName As String = fileToAdd.Replace(" ", "_")

        'A Uri always starts with a forward slash "/" 
        Dim zipUri As String = String.Concat("/", _ 
                   IO.Path.GetFileName(uriFileName)) 

        Dim partUri As New Uri(zipUri, UriKind.Relative) 
        Dim contentType As String = _
                   Net.Mime.MediaTypeNames.Application.Zip

        'The PackagePart contains the information: 
        ' Where to extract the file when it's extracted (partUri) 
        ' The type of content stream (MIME type):  (contentType) 
        ' The type of compression:  (CompressionOption.Normal)   
        Dim pkgPart As PackagePart = zip.CreatePart(partUri, _
                   contentType, CompressionOption.Normal)

        'Read all of the bytes from the file to add to the zip file 
        Dim bites As Byte() = File.ReadAllBytes(fileToAdd)

        'Compress and write the bytes to the zip file 
        pkgPart.GetStream().Write(bites, 0, bites.Length)

    End Sub

源代码原文下载:
Zip Files Easy! The purpose of this article is to demonstrating zipping files using the ZipPackage class in this System.IO.Packaging namespace. This demonstration uses: VB.Net 2008 .Net, Framwork 3.0.

源码图片

点击链接查看大图
从本站下载附件及源代码(1个附件,已经成功下载391次)

最值得关注的外文源代码

Calculator
评论(评论是增加积分的一个有效途径)
字数在300字内
请如实评论
本源代码共评论31次,此处显示最近17次评论! 查看所有评论

65041078  2016年08月19日
学习了,谢谢分享
uqkun09  2015年05月20日
下载! 看看!
wcxfairy  2014年07月05日
谢谢分享!
spliucc  2012年12月12日
学些了 不错
hxkcyjs  2012年08月08日
不错,谢谢
saaf  2012年01月25日
挺好了.
sl  2011年12月23日
可以,学习下。
yl_521649  2011年11月15日
可以用,而且功能很全。不错
han208  2011年11月14日
可以用,谢谢
小蝎  2011年02月06日
试一试
macerfe  2011年01月25日
thanks!
ginger  2009年04月30日
thanks!
suke  2009年03月26日
用一下
shier  2008年12月27日
非常好!
liqbzy  2008年12月08日
还可以
vencent2006  2008年11月21日
收藏了
波波  2008年09月17日
字数在300字内
请如实评论
200万国内源码搜索
CopyRight (C) codesoso.com 2007-2009 All Rights Reserved zhihuishi   免责声明