Question: The program I am working on is currently using a `StreamWriter` to create one or many text files in a target folder. Off `StreamWriter` class, I am using `WriteLine` and its `IDisposable` interface via `Using` directive (for implicit `.Close`). 

I need to add an option to create one or many text files *in a zip archive* inside a target folder. I was going to change existing code to use streams, so it's possible to use a ZIP file as an output (planning to use [DotNetZip](http://dotnetzip.codeplex.com/)).

I was thinking to create some `GetOutputStream` function and feed that into the currently existing method. This function would determine whether *archive* option is set, and either create plain files, or archive them. Problem is that `MemoryStream`, which looks like a good buffer class to use with `DotNetZip`, does not intersect with `StreamWriter` in the inheritance hierarchy.

Looks like my only option is to create some `IWriteLine` interface, which would implement `WriteLine` and `IDisposable`. Then branch two new child classes from `StreamWriter` and `MemoryStream`, and implement `IWriteLine` in them.

Is there a better solution?

The current code conceptually looks like this:

```vb
Using sw As StreamWriter = File.CreateText(fullPath)
  sw.WriteLine(header)
  sw.WriteLine(signature)
  While dr.Read 'dr=DataReader
    Dim record As String = GetDataRecord(dr)
    sw.WriteLine(record)
  End While
End Using

```

For code samples, either **VB.NET** or **C#** is fine, although this is more of a conceptual question.

**EDIT:** Cannot use .NET 4.5's `System.IO.Compression.ZipArchive`, have to stick with .NET 4.0. We still need to support clients running on Windows 2003.

Answer: 
You can make an executable jar file from JarSplice I think.
<http://ninjacave.com/jarsplice>
don't know about the .app part but look at [jarjar](https://code.google.com/p/jarjar/) for embedding libraries in you jar and [here](http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html) for executable jars.