データが書き込まれるときにログファイルを圧縮しています。次のようになります。
using (var fs = new FileStream("Test.gz", FileMode.Create, FileAccess.Write, FileShare.None))
{
  using (var compress = new GZipStream(fs, CompressionMode.Compress))
  {
    for (int i = 0; i < 1000000; i++)
    {
      // Clearly this isn't what is happening in production, just 
      // a simply example
      byte[] message = RandomBytes();
      compress.Write(message, 0, message.Length);
      // Flush to disk (in production we will do this every x lines, 
      // or x milliseconds, whichever comes first)
      if (i % 20 == 0)
      {
        compress.Flush();
      }
    }
  }
}
私が確認したいのは、プロセスがクラッシュまたは強制終了された場合でも、アーカイブは有効で読み取り可能であるということです。前回のフラッシュ以降は何でも安全だと思っていましたが、代わりにアーカイブが破損してしまいました。
フラッシュするたびに読み取り可能なアーカイブを作成する方法はありますか?
注:他の何かで目的の結果が得られる場合は、GZipStreamを使用する必要はありません。