ICSharpCode.SharpZipLib.Zip.ZipFile.GetOutputStream C# (CSharp) Method

GetOutputStream() private method

Get an output stream for the specified ZipEntry
private GetOutputStream ( ZipEntry entry ) : Stream
entry ZipEntry The entry to get an output stream for.
return Stream
        private Stream GetOutputStream(ZipEntry entry) {
            Stream result=baseStream_;

            if (entry.IsCrypted) {
                result=CreateAndInitEncryptionStream(result, entry);
            }

            switch (entry.CompressionMethod) {
                case CompressionMethod.Stored:
                    result=new UncompressedStream(result);
                    break;

                case CompressionMethod.Deflated:
                    var dos=new DeflaterOutputStream(result, new Deflater(9, true));
                    dos.IsStreamOwner=false;
                    result=dos;
                    break;

                default:
                    throw new ZipException("Unknown compression method "+entry.CompressionMethod);
            }
            return result;
        }

Usage Example

Ejemplo n.º 1
0
		void ModifyEntry(ZipFile workFile, ZipUpdate update)
		{
			workFile.WriteLocalEntryHeader(update);
			long dataStart = workFile.baseStream_.Position;

			// TODO: This is slow if the changes don't effect the data!!
			if ( update.Entry.IsFile && (update.Filename != null) ) {
				using ( Stream output = workFile.GetOutputStream(update.OutEntry) ) {
					using ( Stream source = this.GetInputStream(update.Entry) ) {
						CopyBytes(update, output, source, source.Length, true);
					}
				}
			}

			long dataEnd = workFile.baseStream_.Position;
			update.Entry.CompressedSize = dataEnd - dataStart;
		}
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.ZipFile::GetOutputStream