I am trying to read only the first line of a zipped csv file. I used below code but get the error "The magic number in GZIP header is not correct". Obviously it has to do with the fact that GZIP and ZIP are not identical formats but I do not seem to get it working even when using the DotNetZipLib library or SharpZip.
using (GZipStream gzipStream = new GZipStream(File.OpenRead(fileName), CompressionMode.Decompress))
{
using(StreamReader sr = new StreamReader(gzipStream))
{
//Matt try something like this as a hint / starting point
While(sr.Read())
{
row = sr.ReadLine();
}
}
}
Does any of you know how to handle standard zip files (not gzip) and to stream the content to a StreamReader object so that I can easily read the first line of the zipped text file? I do not look for a solution that completely decompresses the whole zip file before opening the text file. I look for a similar solution as above but one that can handle zip files. I also do not want to go the geeky route through byte arrays and having to reconstruct the first row from the array as it would require knowledge of the exact content of the first row (data types, delimiters,...).
Thanks