I've got a file created with code which looks like this:
using (var fs=File.OpenWrite("tmp"))
{
using (GZipStream gs=new GZipStream(fs,CompressionMode.Compress,true))
{
using (StreamWriter sw=new StreamWriter(gs))
{
sw.WriteLine("hello ");
}
}
using (GZipStream gs = new GZipStream(fs, CompressionMode.Compress, true))
{
using (StreamWriter sw = new StreamWriter(gs))
{
sw.WriteLine("world");
}
}
}
Now I'm trying to read the data from this file with following code:
string txt;
using (var fs=File.OpenRead("tmp"))
{
using (GZipStream gs=new GZipStream(fs,CompressionMode.Decompress,true))
{
using (var rdr = new StreamReader(gs))
{
txt = rdr.ReadToEnd();
}
}
using (GZipStream gs = new GZipStream(fs, CompressionMode.Decompress, true))
{
using (StreamReader sr = new StreamReader(gs))
{
txt+=sr.ReadToEnd();
}
}
}
The first stream reads ok, but the second stream doesn't read.
How can I read the second stream?