PowerTCP Zip Compression for .NET
BeginUnzip Method (Archive)
Example 




A directory that will contain the decompressed files.
User state information. Use this to pass data to your EndXXX event handler.
Asynchronously decompress the items in a zip archive that have been opened.
Syntax
<DescriptionAttribute("Begins an asynchronous Unzip operation.")>
Public Function BeginUnzip( _
   ByVal destination As String, _
   ByVal state As Object _
) As IAsyncResult
Dim instance As Archive
Dim destination As String
Dim state As Object
Dim value As IAsyncResult
 
value = instance.BeginUnzip(destination, state)
[Description("Begins an asynchronous Unzip operation.")]
public IAsyncResult BeginUnzip( 
   string destination,
   object state
)
[Description("Begins an asynchronous Unzip operation.")]
public: IAsyncResult* BeginUnzip( 
   string* destination,
   Object* state
) 
[Description("Begins an asynchronous Unzip operation.")]
public:
IAsyncResult^ BeginUnzip( 
   String^ destination,
   Object^ state
) 

Parameters

destination
A directory that will contain the decompressed files.
state
User state information. Use this to pass data to your EndXXX event handler.

Return Value

An IAsyncResult that represents the asynchronous operation, which could still be pending.
Exceptions
ExceptionDescription
ZipExceptionA critical zip operation error occurred during this activity. Please see ZipException.Message for details.
Remarks

The Archive.PreservePath property determines whether to preserve the paths. The Archive.Overwrite property determines whether and how an existing file will be overwritten. By default, the paths will not be preserved and the overwrite choice is Overwrite.Never.

If an error occurs for an individual item during this operation, the Archive.Exception Event will be raised.

Example
The following example demonstrates loading a compressed file and asynchronously unzipping the contents.
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Zip"
' at the top of your class.

' Open a compressed stream.  This populates the Archive collection.
Archive1.Open("c:\test.zip")

' Preserve the path structure and overwrite any existing files.
Archive1.PreservePath = True
Archive1.Overwrite = Overwrite.Always

' Begin an asynchronous unzip process
Archive1.BeginUnzip("c:\test", Nothing)

Private Sub Archive1_EndUnzip(ByVal sender As Object, ByVal e As Dart.PowerTCP.Zip.EndEventArgs) Handles Archive1.EndUnzip
    Try
        ' Check for any zip operation exceptions
        If e.Exception Is Nothing Then
            MessageBox.Show("Extraction Complete!")
        Else
            MessageBox.Show(e.Exception.Message)
        End If

    Catch

    End Try
End Sub
// Be sure to import the namespace by putting "using Dart.PowerTCP.Zip;"
// at the top of your class.

// Open a compressed stream.  This populates the Archive collection.
archive1.Open("c:\\test.zip");

// Preserve the path structure and overwrite any existing files.
archive1.PreservePath = true;
archive1.Overwrite = Overwrite.Always;

// Begin an asynchronous unzip process
archive1.BeginUnzip("c:\\test",null);

private void archive1_EndUnzip(object sender, Dart.PowerTCP.Zip.EndEventArgs e)
{
	try
	{
		if (e.Exception == null)
			MessageBox.Show("Extraction Complete!");
		else
			MessageBox.Show(e.Exception.Message);
	}
	catch {}

}
See Also

Reference

Archive Class
Archive Members


PowerTCP Zip for .NET Documentation Version 2.1.1
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic