ZForge.Zip.ZipEntry.Read C# (CSharp) Method

Read() public static method

Reads one ZipEntry from the given stream.
public static Read ( System s ) : ZipEntry
s System the stream to read from.
return ZipEntry
        public static ZipEntry Read(System.IO.Stream s)
        {
            ZipEntry entry = new ZipEntry();

            if (!ReadHeader(s, entry)) return null;

            entry.__filedata = new byte[entry.CompressedSize];
            int n = s.Read(entry._FileData, 0, entry._FileData.Length);
            if (n != entry._FileData.Length)
            {
                throw new Exception("badly formatted zip file.");
            }
            // finally, seek past the (already read) Data descriptor if necessary
            if ((entry._BitField & 0x0008) == 0x0008)
            {
                s.Seek(16, System.IO.SeekOrigin.Current);
            }
            return entry;
        }