Reputation: 25367
I'm working on a log program, which would dump data into gzip archive.
The first entry would look like this:
using (var fs = File.OpenWrite(logFile))
{
using (var gs = new GZipStream(fs, CompressionMode.Compress))
{
using (var sw = new StreamWriter(gs))
{
sw.WriteLine(logEntry);
}
}
}
Now I want add other lines to that file without having to re-read all file content and than to re-write it in a way that the result can be read with a single GZipStream.
What is the best way to do that?
Upvotes: 1
Views: 1536
Reputation: 112547
You can use gzlog.h
and gzlog.c
from the zlib distribution in the examples directory. They do exactly what you're looking for.
Upvotes: 1