Xceed Real-Time Zip for .NET Documentation
AllowOutputStreamClosure Property
Example 


Xceed.Zip Assembly > Xceed.Zip.ReaderWriter Namespace > ZipWriter Class : AllowOutputStreamClosure Property
Gets or sets a boolean value indicating whether the output stream can be closed by the object.
Syntax
'Declaration
 
Public Property AllowOutputStreamClosure As Boolean
'Usage
 
Dim instance As ZipWriter
Dim value As Boolean
 
instance.AllowOutputStreamClosure = value
 
value = instance.AllowOutputStreamClosure
public bool AllowOutputStreamClosure {get; set;}

Property Value

true if the output stream can be closed by the object; false otherwise. By default, false.
Remarks

Since ZipWriter does not create the output stream it is given, it does not close it when the zip operation is finished.

However, there are situations where it is convenient to close the output stream when ZipWriter is done. This is especially true when the output stream is exclusively tied to the ZipWriter, is not needed afterwards and ZipWriter is wrapped in a "using" statement (see example).

In these cases, setting the property to true will make ZipWriter close the output stream when Dispose is called.

The output stream will not be closed when CloseZipFile is called.

When the property is set to true, it allows for cleanup of both ZipWriter and the output stream in one "using" statement. When set to false it is your responsibility to close the output stream once ZipWriter is done with it.

Example

When the property is set to true, it allows for cleanup of both ZipWriter and the output stream in one 'using' statement (Example 1).

When the property is set to false, it is your responsibility to close the output stream once ZipWriter is done with it (Example 2).

using( ZipWriter writer = new ZipWriter( new SomeOutputStream(), false, true ) )
{
  // Use 'writer'
}
Using writer As New ZipWriter(New SomeOutputStream(), False, True)
  ' Use 'writer'
End Using
using( Stream outputStream = new SomeOutputStream() )
{
  using( ZipWriter writer = new ZipWriter( outputStream, false, false ) )
  {
    // Use 'writer'
  }
}
Using outputStream As Stream = New SomeOutputStream()
  Using writer As New ZipWriter(outputStream, False, False)
    ' Use 'writer'
  End Using
End Using
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ZipWriter Class
ZipWriter Members