I am trying to do some of my own programmatic analysis of data recently purchased and downloaded from QC, specifically it is GBPUSD in second resolution.  When trying to read these files programmatically in C#, I get an error, “System.IO.InvalidDataException: 'A local file header is corrupt.'”  This also happened to me with GBPUSD hourly data, which was not too big of an issue thanks to the workaround below.

The way I got around this error is by manually extracting the .zip, then zipping the files back into a .zip.  When trying to access this rezipped file programmatically, it works fine.  Unless someone can correct me, this suggests that something is wrong with the original downloaded .zip files.  I want to ask here what's wrong before I resort to scripting to massage these zip files.  Since this is paid for data, I hope that there is no corruption going on.  Am I doing something wrong to access these files or is there something wrong with how these files are zipped?

 

List<BarData> barDatas = new List<BarData>();

using (ZipArchive archive = ZipFile.OpenRead(barDataFilePath))
{
    foreach (ZipArchiveEntry entry in archive.Entries)
    {
        if (entry.FullName.EndsWith(".csv", StringComparison.OrdinalIgnoreCase))
        {
            using (StreamReader streamReader = new StreamReader(entry.Open()))//Error occurs here
            {
            }
        }
    }
}