惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Hacker News: Ask HN
Hacker News: Ask HN
L
Lohrmann on Cybersecurity
PCI Perspectives
PCI Perspectives
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
月光博客
月光博客
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
The GitHub Blog
The GitHub Blog
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
F
Full Disclosure
U
Unit 42
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
腾讯CDC
T
Threatpost
H
Hacker News: Front Page
P
Palo Alto Networks Blog
博客园 - 聂微东
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Spread Privacy
Spread Privacy

博客园 - 张远强

原版SQLHelper.cs下载 Chrome浏览器Proxy Switchy、Tampermonkey等扩展程序下载 GreaseMonkey脚本:阻止Google转换搜索链接地址 站在31岁,理解程序员年过三十这道坎 GreaseMonkey让网站登录验证码形同虚设 DateTime.ToString格式限定符转义 借Windows说明Linux分区和挂载点 JSON解析类(C#) 彻底解决ASP.NET MD5加密中文结果和ASP不一致的问题 DotNetZip使用示例 Dvbbs 8.2.0 RC1多功能编辑器,提供下载 B/S系统版本管理V1.0正式发布 ASP.NET 2.0缓存 个人网站与动网整合步骤(支持PDO1.0) - 张远强 - 博客园 C#中显/隐式实现接口及其访问方法 C#接口范例 巧用escape解决ASP.NET中URL传参乱码问题 使用Filter实现信息的二次检索 使用overflow代替left截取指定长度字符串
SharpZipLib使用示例
张远强 · 2009-02-26 · via 博客园 - 张远强

SharpZipLib是一个使用C#编写的Zip操作类库,在VB.NET、C#或其他的.NET语言中都可以使用它创建Zip文件、并进行读取和更新等操作。SharpZipLib目前的版本为0.85,下边通过几个例子来说明它的使用(使用前需引用命名空间ICSharpCode.SharpZipLib.Zip)。

1.创建zip文件,无法添加文件夹

using (ZipFile zip = ZipFile.Create(@"E:\test.zip"))
{
    zip.BeginUpdate();
    zip.Add(
@"E:\五笔打字法.txt");
    zip.Add(
@"E:\网站推广方法.txt");
    zip.CommitUpdate();
}

2.创建zip文件,只能压缩文件夹

(new FastZip()).CreateZip(@"E:\test.zip"@"E:\test\"true"");

3.添加一个文件到zip文件中,无法添加文件夹

using (ZipFile zip = new ZipFile(@"E:\test.zip"))
{
    zip.BeginUpdate();
    zip.Add(
@"E:\房屋租赁协议.doc");
    zip.CommitUpdate();
}

4.列出zip文件中所有的文件

using (ZipFile zip = new ZipFile(@"E:\test.zip"))
{
    
string list = string.Empty;
    
foreach (ZipEntry entry in zip)
    
{
        list 
+= entry.Name + "\r\n";
    }

    MessageBox.Show(list);
}

5.删除zip文件中的一个文件

using (ZipFile zip = new ZipFile(@"E:\test.zip"))
{
    zip.BeginUpdate();
    zip.Delete(
@"房屋租赁协议.doc");
    zip.Delete(
@"a\2.txt");
    zip.CommitUpdate();
}

6.解压zip文件中所有文件

(new FastZip()).ExtractZip(@"E:\test.zip"@"E:\mzwucom\""");


官方站点: http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx