通过代码解压缩时出错 [英] Error while Unzipping by code

查看:143
本文介绍了通过代码解压缩时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dim directory As New IO.DirectoryInfo("***")
  Dim fileA As IO.FileInfo() = directory.GetFiles("*.gz")
  Dim Origin As String = "***"
  Dim Destination As String = "***"
  Dim ZipFileToExtract As String = ""

  For Each fi As IO.FileInfo In fileA
      ZipFileToExtract = Origin & fi.Name
      Dim inStream As Stream = File.OpenRead(ZipFileToExtract)
      Dim gzipStream As Stream = New GZipInputStream(inStream)

      Dim tarFile As TarArchive =    TarArchive.CreateInputTarArchive(gzipStream)
      tarFile.ExtractContents(Destination)

      inStream.Dispose()
      gzipStream.Dispose()
  Next


它给了我这个错误:
标头校验和无效

在此行:
tarFile.ExtractContents(Destination)


It is giving me this error:
Header checksum is invalid

At this line:
tarFile.ExtractContents(Destination)

推荐答案

您确定文件是使用TAR归档的吗?该扩展名并不表示它是"tar球",通常以"tar.gz"或".tgz"结尾.有关更多详细信息,请参见 http://en.wikipedia.org/wiki/Gzip [
Are you sure the file was archived with TAR? The extension does not suggest it''s a "tar ball", which is usually end with ''tar.gz'' or ''.tgz''. For more detail, see http://en.wikipedia.org/wiki/Gzip[^].

—SA


这篇关于通过代码解压缩时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆