是否可以将SevenZipSharp的提取输出动态写入文件而不是内存然后写入文件?
我写入流而不是直接写入文件的原因是检查特定位置的字节(以确定要提取的文件的版本)我希望尽快获得此值,而不是而不是提取文件后。
示例代码有效,但速度极慢,我无法找出在事件中编写流的方法。 Dim ms As New MemoryStream
Private Sub Test()
Using tmp = New SevenZipExtractor(FILENAME)
AddHandler tmp.Extracting, AddressOf SevenZip_Extracting
AddHandler tmp.ExtractionFinished, AddressOf SevenZip_ExtractionFinished
tmp.ExtractFile(0, ms)
End Using
End Sub
Private Sub SevenZip_Extracting(ByVal sender As Object, ByVal e As ProgressEventArgs)
' Read Bytes at position 3756 (b * 256 + a)
If e.PercentDone = 1 Then
Dim br As BinaryReader = New BinaryReader(ms)
Dim lngStartPos As Long = 3756
br.BaseStream.Seek(lngStartPos, SeekOrigin.Begin)
Dim a As Byte = br.ReadByte()
Dim b As Byte = br.ReadByte()
Console.WriteLine(b * 256 + a)
End If
Using fs As FileStream = File.OpenWrite("C:\Temp\output.tmp")
ms.WriteTo(fs)
End Using
End Sub