我正在使用 SharpZipLib 压缩文件。该库包装在一个插件接口中,在一个单独的 DLL 中。我向插件 dll 传递了一个ByRef
参数来跟踪压缩进度。
SharpZipLib 在压缩时会定期调用在启动压缩时传递的委托子。ByRef
我不知道在调用委托时如何更新参数。如果我尝试ByRef
在 Lamba 表达式的主体中分配变量,则会出现'ByRef' parameter '<parametername>' cannot be used in a lambda expression
错误。
这是我的代码:
Using InputFile As New IO.FileStream(SourceFile, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using OutputFile As New IO.FileStream(DestFile, IO.FileMode.Create)
Using GZipStream As New GZipOutputStream(OutputFile)
Dim Buffer(524228) As Byte
Dim Handler As New ProgressHandler(Sub(Sender As Object, EventArgs As ProgressEventArgs) Progress += EventArgs.Processed)
StreamUtils.Copy(InputFile, GZipStream, Buffer, Handler, New TimeSpan(10000000), Nothing, "")
End Using
End Using
End Using
谢谢!