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

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - fisherman

学习写第一个SQL server触发器 操纵自如--页面内的配合与通信 一些DIV+CSS 命名规范 asp.net 2.0中生成RSS 避免重复提交 - fisherman - 博客园 button 删除确认 - fisherman - 博客园 用相对定位和负向移动完成图片象框阴影 负边距居中法(水平居中、垂直居中) - fisherman - 博客园 CSS 代码格式化工具 - fisherman - 博客园 JS代码的格式化和压缩 - fisherman - 博客园 把SQL SERVER里表里的数据导出成为insert into 脚本 对FckEditor编辑器在MAXTHON浏览器下选择服务器文件对话框显示不正常的改进 下载网页中远程图片的方法 读取marc数据 关于ISO2709数据的格式说明 C#写的读取ISO2709格式数据的DLL 数据库打开 使用 Engine 对象创建 SQL Server Compact Edition 数据库 Access数据库压缩和修复
用SharpZipLib压缩和解压缩文件
fisherman · 2007-05-30 · via 博客园 - fisherman


第一步:添加引用文件:
ICSharpCode.SharpZipLib.dll

第二步:导入名称空间:Imports ICSharpCode.SharpZipLib.Zip

第三步:a、压缩函数

'<summary>
    ' Create a zip archive.
    ' </summary>
    ' <param name="filename">The filename.</param>
    ' <param name="directory">The directory to zip.</param> 
    Public Shared Sub PackFiles(ByVal filename As StringByVal directory As String)
        
Try
            
Dim fz As FastZip = New FastZip()
            fz.CreateEmptyDirectories 
= True
            fz.CreateZip(filename, directory, 
True"")
            fz 
= Nothing
        
Catch
            
Throw
        
End Try
End Sub

       b、解压缩文件

'<summary>
    'Unpacks the files.
    '</summary>
    '<param name="file">The file.</param>
    '<returns>if succeed return true,otherwise false.</returns>
    Public Shared Function UnpackFiles(ByVal file As StringByVal dir As StringAs Boolean
        
Try
            
'
            If Not Directory.Exists(dirThen
                Directory.CreateDirectory(
dir)
            
End If
            
Dim s As ZipInputStream = New ZipInputStream(IO.File.OpenRead(file))
            
Dim theEntry As ZipEntry
            theEntry 
= s.GetNextEntry()

            
While Not IsNothing(theEntry)

                
Dim directoryName As String = Path.GetDirectoryName(theEntry.Name)
                
Dim fileName As String = Path.GetFileName(theEntry.Name)

                
If directoryName <> String.Empty Then
                    Directory.CreateDirectory(
dir + directoryName)
                
End If



                
If fileName <> String.Empty Then
                    
Dim StreamWriter As FileStream = IO.File.Create(dir + theEntry.Name)

                    
Dim Size As Integer = 2048
                    
Dim data(2048As Byte
                    
While (True)
                        Size 
= s.Read(data, 0, data.Length)
                        
If Size > 0 Then
                            StreamWriter.Write(data, 
0, Size)
                        
Else
                            
Exit While
                        
End If
                    
End While

                    StreamWriter.Close()
                
End If
                
'
                theEntry = s.GetNextEntry()
            
End While
            s.Close()
            
Return True
        
Catch ex As Exception
            
Throw
        
End Try
    
End Function

实例图:

点击下载