Exemple #1
0
 private void WriteLocalFileHeaderAndDataIfNeeded()
 {
     if (this._storedUncompressedData == null && this._compressedBytes == null)
     {
         if (this._archive.Mode == ZipArchiveMode.Update || !this._everOpenedForWrite)
         {
             this._everOpenedForWrite = true;
             this.WriteLocalFileHeader(true);
         }
     }
     else if (this._storedUncompressedData == null)
     {
         if (this._uncompressedSize == 0)
         {
             this.CompressionMethod = ZipArchiveEntry.CompressionMethodValues.Stored;
         }
         this.WriteLocalFileHeader(false);
         using (MemoryStream memoryStream = new MemoryStream(this._compressedBytes))
         {
             memoryStream.CopyTo(this._archive.ArchiveStream);
         }
     }
     else
     {
         this._uncompressedSize = this._storedUncompressedData.Length;
         using (Stream directToArchiveWriterStream = new ZipArchiveEntry.DirectToArchiveWriterStream(this.GetDataCompressor(this._archive.ArchiveStream, true, null), this))
         {
             this._storedUncompressedData.Seek((long)0, SeekOrigin.Begin);
             this._storedUncompressedData.CopyTo(directToArchiveWriterStream);
             this._storedUncompressedData.Close();
             this._storedUncompressedData = null;
         }
     }
 }