public override int Read(byte[] buffer, int offset, int count) { int i; for (i = 0; i < count && Position < Length; i++) { buffer[i + offset] = (byte)inStream.ReadByte(); } return(i); }
public FileUnpacker(string filePathtoUnpack, CryptoClass crypto, CancellationToken ct) { Token = ct; filePath = filePathtoUnpack; this.crypto = crypto; inputStream = new FileStream(filePathtoUnpack, FileMode.Open, FileAccess.Read); compressInfo = new CompressionInfo(inputStream, crypto); try { decompStream = new DecompressionStream(inputStream, compressInfo, crypto); decompStream.ReadByte(); decompStream.Dispose(); } catch (System.Security.Cryptography.CryptographicException) { inputStream.Dispose(); throw new IncorrectKeyException(); } fileDatas = compressInfo.Files; inputStream.Dispose(); }