Using GZipStream to open downloaded gzip files and get the xml file inside.
Problem is that sometimes the whole xml file isn't extracted by my code:
private static string Unzip(string fileToUnzip, string format)
{
string unzippedFileName = fileToUnzip.Replace(".zip", format);
FileInfo fi = new FileInfo(fileToUnzip);
using (FileStream inFile = fi.OpenRead())
{
try
{
using (FileStream outFile = File.Create(unzippedFileName))
{
using (GZipStream Decompress = new GZipStream(inFile,
CompressionMode.Decompress, true))
{
Decompress.CopyTo(outFile);
}
}
}
catch(Exception ex)
{
int k = 0;
}
}
return unzippedFileName;
}
There is nothing wrong with the gzip files, I can get the xml fil manually using WinRAR.
No exceptions are thrown.
Any ideas for what is going wrong?