System.IO.Compression.ZipHelper.ReadBytes C# (CSharp) Méthode

ReadBytes() static private méthode

static private ReadBytes ( Stream stream, byte buffer, int bytesToRead ) : void
stream Stream
buffer byte
bytesToRead int
Résultat void
        internal static void ReadBytes(Stream stream, byte[] buffer, int bytesToRead)
        {
            int bytesLeftToRead = bytesToRead;

            int totalBytesRead = 0;

            while (bytesLeftToRead > 0)
            {
                int bytesRead = stream.Read(buffer, totalBytesRead, bytesLeftToRead);
                if (bytesRead == 0) throw new IOException(SR.UnexpectedEndOfStream);

                totalBytesRead += bytesRead;
                bytesLeftToRead -= bytesRead;
            }
        }

Usage Example

Exemple #1
0
 internal bool LoadLocalHeaderExtraFieldAndCompressedBytesIfNeeded()
 {
     if (this._originallyInArchive)
     {
         this._archive.ArchiveStream.Seek(this._offsetOfLocalHeader, SeekOrigin.Begin);
         this._lhUnknownExtraFields = ZipLocalFileHeader.GetExtraFields(this._archive.ArchiveReader);
     }
     if (!this._everOpenedForWrite && this._originallyInArchive)
     {
         this._compressedBytes = new byte[checked ((IntPtr)this._compressedSize)];
         this._archive.ArchiveStream.Seek(this.OffsetOfCompressedData, SeekOrigin.Begin);
         ZipHelper.ReadBytes(this._archive.ArchiveStream, this._compressedBytes, (int)this._compressedSize);
     }
     return(true);
 }
All Usage Examples Of System.IO.Compression.ZipHelper::ReadBytes