VB.NET中解压ZIP文件代码问题
以下是我的代码Public Sub ExtractArchive(ByVal ZIPpath As String, ByVal folder As String, ByVal uri As String)
ZIPpath = "D:\TEMP\2010080501_OPRJ.zip"
folder = "D:\\TEMP"
uri = "/2010080501_OPRJ.xls"
Dim zip As Package = ZipPackage.Open(ZIPpath, IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite)
Dim pkgPart As PackagePart = Nothing
Try
If folder <> String.Empty Then
Dim partUri As Uri = New Uri(uri, System.UriKind.Relative)
pkgPart = zip.GetPart(partUri) '这句就报错
Dim fileName As String = uri
If IO.Path.GetExtension(fileName) = ".psmdcp" OrElse fileName.IndexOf("_rels") > -1 Then Exit Sub
Dim stream As Stream = pkgPart.GetStream()
Dim bites(CInt(stream.Length - 1)) As Byte
stream.Read(bites, 0, bites.Length)
fileName = fileName.Replace("_", " ") 'replace underscore with space
File.WriteAllBytes(String.Concat(folder, "\", fileName), bites)
zip.Close()
End If
Catch ex As Exception
zip.Close()
Throw ex
End Try
End Sub
报错是说:数据包中不存在指定部件。
但是我的ZIP包里肯定有这个文件,所以感到不解。。
请大侠帮忙看一下问题在哪里,谢谢啦 --------------------编程问答-------------------- http://vbnet.5d6d.com/thread-57-1-1.html
用这个试试…… --------------------编程问答-------------------- 建议调用dos方式下的rar.exe,shell时加wait --------------------编程问答--------------------
补充:.NET技术 , VB.NET