VB.NET用SharpZipLib解压.gzip文件

qq_34106772 2018-10-17 04:09:50
各位老师好,我打算用SharpZipLib解压.gzip文件,我修改了网上的一段程序,可以解压.zip:
Public Shared Sub DecompressZip(ByVal zipPath As String, ByVal folderPath As String)
'目标文件夹路径
Dim z As New ZipInputStream(File.OpenRead(zipPath))
Dim t As ZipEntry
Dim fp As String
' 开始循环解压
Do
t = z.GetNextEntry
If t Is Nothing Then Exit Do
fp = folderPath & t.Name
fp = folderPath
'如果是文件夹则创建文件夹
If t.IsDirectory AndAlso Not Directory.Exists(fp) Then
Directory.CreateDirectory(fp)
ElseIf t.IsFile Then
'如果是文件则解压文件
If (Not File.Exists(fp)) Then
Dim sw As FileStream = File.Create(fp)
Dim size As Integer
Dim data(2048) As Byte
Do '循环读取数据
size = z.Read(data, 0, data.Length)
If size = 0 Then Exit Do
sw.Write(data, 0, size)
Loop
sw.Close()
End If
End If
Loop
z.Close()
End Sub

上面程序是可以运行的,但是我想套用去解压gzip文件,把Dim z As New ZipInputStream(File.OpenRead(zipPath)) 改为Dim z As New GZipInputStream(File.OpenRead(zipPath)),之后 t = z.GetNextEntry这句会报错,提示GetNextEntry不是GZipInputStream的成员,我不知道怎么改为.gzip的格式,请帮忙看下是哪里的语法错误了。
...全文
291 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
思考 2018-10-19
  • 打赏
  • 举报
回复
gzip?没有这样文件啊,没法试

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧