【发布时间】:2016-03-20 15:56:49
【问题描述】:
我使用 SevenZipSharp 库生成了一个多卷 7z 文件。
我遇到的问题是,当我尝试提取文件时,我得到一个关于无效转换的异常:
无法投射对象
类型为“SevenZip.InMultiStreamWrapper”的类型为“SevenZip.InStreamWrapper”。
抛出异常的方法是SevenZipExtractor.Check()。
这是用 Vb.Net 编写的用于重现提取问题的示例代码,但我也可以接受 C# 解决方案:
Public Overridable Function Extract(ByVal sourceFilePath As String,
ByVal outputDirectorypath As String,
ByVal password As String) As String
If String.IsNullOrEmpty(password) Then
Me.extractor = New SevenZipExtractor(sourceFilePath)
Else
Me.extractor = New SevenZipExtractor(sourceFilePath, password)
End If
' Check for password matches doing an integrity check.
If Me.extractor.Check() Then
' Start the extraction.
Me.extractor.ExtractArchive(outputDirectorypath)
Else
Throw New Exception(
"Failed to extract, maybe the provided password does not match?.")
End If
Return outputDirectorypath
End Function
如果我忽略完整性检查,使用设置了密码的多卷文件,那么我无法提取它,因为发生另一个异常...
可能是他们的源代码中的一个错误,但我要求确定,因为库不支持提取多卷文件很奇怪......
【问题讨论】:
标签: c# .net vb.net 7zip sevenzipsharp