SharpZipLibを使用してファイルを圧縮しています。ライブラリは、別のDLLのプラグインインターフェイスにラップされています。プラグインdllにByRef
パラメーターを渡して、圧縮の進行状況を追跡します。
SharpZipLibは、圧縮中に、圧縮の起動時に渡されたデリゲートサブを定期的に呼び出します。ByRef
デリゲートが呼び出されたときにパラメーターを更新する方法がわかりません。ByRef
ランバ式の本体に変数を割り当てようとすると、'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
ありがとう!