Wednesday, 18 September 2013

Zip File Entry has custom file extension. C# claims it cannot open

Zip File Entry has custom file extension. C# claims it cannot open

I have a zip file given to us by a 3rd party. In this zip files are custom
files. These are just text files with a different extension, which I
assume is just to frustrate me.
I'm trying to open this files in my C# application, but it keeps throwing
the error that the format is not supported.
Since these are just text files, I feel there must be some way for this to
happen.
If anyone has any ideas, please let me know.
Code:
using (ZipArchive archive = ZipFile.OpenRead(_trailerName))
{
ZipArchiveEntry entry = archive.GetEntry(tableChanged + ".trl");
Stream ms = entry.Open(); //Here is what's causing the issue.
StreamReader reader = new StreamReader(ms);
string allLinesRead = reader.ReadToEnd();
string[] everyCell = allLinesRead.Split('|');
int numRecords = Convert.ToInt32(everyCell[1]);
int numChanged = getRecordNum(tableChanged);
Console.Write(numRecords + "/" + numChanged + " - " + tableChanged);
if (numChanged != numRecords)
{
_errorMessage += "Records updated do not match trailer. (" +
numRecords + "/" + numChanged + ") Please check database. Table
affected: " + tableChanged + Environment.NewLine;
}
}
Error:
The given path's format is not supported.
I know this is specific, but I need advice on what steps I can take to
resolve this.
Thanks.

No comments:

Post a Comment