サードパーティの fms ログを解析する機能に取り組んできました。ログは Gzip にあるため、使用する他の Gzip ファイルで機能する解凍機能を使用します。
これらのファイルを解凍すると、圧縮ファイルの最初の行のみが取得されます。例外はありません。最初の行にEOFがあるかのように、残りのバイトが見つかりません。System.IO.Compression の代わりに Ionic.Zlib を使用してみましたが、結果は同じでした。ファイルが破損しているようには見えず、Winrar で解凍するとうまくいきます。
誰かがこれを解決する方法を知っているなら、私はあなたの助けに感謝します. ありがとう
ここからサンプル ファイルをダウンロードできます: http://www.adjustyourset.tv/fms_6F9E_20120621_0001.log.gz
これは私の解凍関数です:
public static bool DecompressGZip(String fileRoot, String destRoot)
{
try
{
using (FileStream fileStram = new FileStream(fileRoot, FileMode.Open, FileAccess.Read))
{
using (FileStream fOutStream = new FileStream(destRoot, FileMode.Create, FileAccess.Write))
{
using (GZipStream zipStream = new GZipStream(fileStram, CompressionMode.Decompress, true))
{
byte[] buffer = new byte[4096];
int numRead;
while ((numRead = zipStream.Read(buffer, 0, buffer.Length)) != 0)
{
fOutStream.Write(buffer, 0, numRead);
}
return true;
}
}
}
}
catch (Exception ex)
{
LogUtils.SaveToLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "Eror decompressing " + fileRoot + " : " + ex.Message, Constants.systemLog, 209715200, 6);
return false;
}
}