Reading binary from zip file from C # without unzipping it
I would like to read a binary from a zip file without unpacking it.
Zip file structure:
zipFolderName/subFolder/BinFile
In BinFile, I have:
Id1, id2, value1 // id1, id2 are string, value1 is int
In C #:
ZipEntry binFileName = …; // it has been got from zipFile entries
MemoryStream ms = new MemoryStream();
binFileName.Extract(ms);
using (BinaryReader reader = new BinaryReader(ms))
{
string id1 = reader.ReadString(); // error popped here
string id2 = reader.ReadString();
int value1 = reader.ReadInt32();
}
I got the error: Unable to read outside of stream. Seems like BinaryReader can't read MemoryStream?
+3
source to share