The method creates a new write-only, non-seeking stream object based on the ZipWriter instance's current item. Each call to the stream's Stream.Write method will call WriteItemData.
The method allows you to use the Stream class interface to write item data into ZipWriter instead of using WriteItemData directly. This makes it possible to integrate ZipWriter with
other classes that use the Stream class interface without the need for "glue code."
Dispose should be called on the stream when all the current item's data has been written.
The stream returned by the method should be considered unique to the current item. This means you should not reuse the stream with later items. Instead, get a new stream instance by calling the method again. The example below illustrates this.
WriteItemData can still be called to write data even if this method is used. This can be done after the stream returned by the method has been closed or even while the stream is active.
The method can be used to create nested zip archives with ZipWriter. A nested zip archive is when an item in an archive is another zip archive. By providing the stream returned by the method to a new instance of ZipWriter, a nested zip archive will be created. See this page for an example.
The following examples show how to create a ZipWriter instance that will write into a stream that has been prepared.
.NET: net5.0, net5.0-windows, net6.0, net6.0-macos, net6.0-windows, net7.0, net7.0-macos, net7.0-windows, net8.0, net8.0-browser, net8.0-macos, net8.0-windows, net9.0, net9.0-browser, net9.0-macos, net9.0-windows, net10.0, net10.0-browser, net10.0-macos, net10.0-windows.
.NET Framework: net40, net403, net45, net451, net452, net46, net461, net462, net463, net47, net471, net472, net48, net481.