PowerTCP Zip Compression for .NET
EndZip Event
Example 




Occurs when an asynchronous zip operation completes
Syntax
<DescriptionAttribute("Raised when a BeginZip operation completes.")>
<CategoryAttribute("Completion")>
Public Event EndZip As EndEventHandler
Dim instance As Archive
Dim handler As EndEventHandler
 
AddHandler instance.EndZip, handler
[Description("Raised when a BeginZip operation completes.")]
[Category("Completion")]
public event EndEventHandler EndZip
[Description("Raised when a BeginZip operation completes.")]
[Category("Completion")]
public: __event EndEventHandler* EndZip
[Description("Raised when a BeginZip operation completes.")]
[Category("Completion")]
public:
event EndEventHandler^ EndZip
Event Data

The event handler receives an argument of type EndEventArgs containing data related to this event. The following EndEventArgs properties provide information specific to this event.

PropertyDescription
Exception Gets the Exception that occurred.  
State Returns any state information included with this event.  
Remarks
if an error occurs during the unzip operation, Archive.EndEventArgs.Exception can be checked for the exception.
Example
The following example demonstrates adding files to the collection and asynchronously zipping them.
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Zip"
' at the top of your class.

' Add a file using the ArchiveItem constructor
Dim item = New ArchiveItem("c:\Test\file1.txt")

' Add a comment to this item
item.Comment = "This is file1.txt"

' Use encryption for just this item
item.Encryption = Encryption.Standard
item.Password = "testme"

Archive1.Add(item)

' Add a file using the filename.  This could also be used for adding wildcard collections
Archive1.Add("c:\Test\file2.log")

' Add a wildcard collection of files
' In this case, all "txt" files in the directory "c:\Test" are added, except "file1.txt"
' Subfolders are not included, but the paths are preserved.
Archive1.IncludeSubs = True
Archive1.ExcludePattern = "file1.txt"
Archive1.PreservePath = True
Archive1.Add("c:\Test\*.txt")

' Start the zipping processes
Archive1.BeginZip("c:\test.zip", Nothing)

Private Sub Archive1_EndZip(ByVal sender As Object, ByVal e As Dart.PowerTCP.Zip.EndEventArgs) Handles Archive1.EndZip
    Try
        If e.Exception Is Nothing Then
            MessageBox.Show("Zip 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.

// Add a file using the ArchiveItem constructor
ArchiveItem item = new ArchiveItem("c:\\Test\\file1.txt");

// Add a comment to this item
item.Comment = "This is file1.txt";

// Use encryption for just this item
item.Encryption = Encryption.Standard;
item.Password = "testme";

archive1.Add(item);

// Add a file using the filename.  This could also be used for adding wildcard collections
archive1.Add("c:\\Test\\file2.log");

// Add a wildcard collection of files
// In this case, all "txt" files in the directory "c:\Test" are added, except "file1.txt"
// Subfolders are not included, but the paths are preserved.
archive1.IncludeSubs = true;
archive1.ExcludePattern= "file1.txt";
archive1.PreservePath = true;
archive1.Add("c:\\Test\\*.txt");

// Start the zipping processes
archive1.BeginZip("c:\\test.zip", null);

private void archive1_EndZip(object sender, Dart.PowerTCP.Zip.EndEventArgs e)
{
	try
	{
		if (e.Exception == null)
			MessageBox.Show("Zip 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