PowerTCP Zip Compression for .NET
QuickZip(String,Stream) Method
Example 




The names or wildcards of the files to be compressed.
A Stream that is to contain the compressed data.
Adds a file or files and compresses in one step.
Syntax
<DescriptionAttribute("To compress a given source, wildcard")>
Public Overloads Sub QuickZip( _
   ByVal source As String, _
   ByVal destination As Stream _
) 
Dim instance As Archive
Dim source As String
Dim destination As Stream
 
instance.QuickZip(source, destination)
[Description("To compress a given source, wildcard")]
public void QuickZip( 
   string source,
   Stream destination
)
[Description("To compress a given source, wildcard")]
public: void QuickZip( 
   string* source,
   Stream* destination
) 
[Description("To compress a given source, wildcard")]
public:
void QuickZip( 
   String^ source,
   Stream^ destination
) 

Parameters

source
The names or wildcards of the files to be compressed.
destination
A Stream that is to contain the compressed data.
Exceptions
ExceptionDescription
ZipExceptionA critical zip operation error occurred during this activity. Please see ZipException.Message for details.
Remarks

This method is a quick and easy way to use the Archive component to compress a given file or files to a specified destination stream. It combines the two operations of Archive.Add and Archive.Zip.

The Archive.Password and Archive.Encryption properties are used for data encryption during the QuickZip operation. The Archive.PreservePath property determines whether to preserve paths for each file item. The Archive.IncludeSubs property determines whether to include the subdirectories. The Archive.ExcludePattern property determines the files to exclude.

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

Example
The following example demonstrates using QuickZip with a stream as a destination.
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Zip"
' at the top of your class.

' Preserve the path structure of the files
Archive1.PreservePath = True

' Include any subdirectories
Archive1.IncludeSubs = True

' Exclude any text files
Archive1.ExcludePattern = "*.txt"

' Set to use encryption
Archive1.DefaultEncryption = Encryption.Standard

' Specify the password
Archive1.Password = "testme"

' Create a stream
Dim stream = New System.IO.MemoryStream()

' QuickZip to the stream
Archive1.QuickZip("c:\Test\*.*", stream)

MessageBox.Show("The size of the compressed stream is " + stream.Length.ToString() + " bytes.")
// Be sure to import the namespace by putting "using Dart.PowerTCP.Zip;"
// at the top of your class.

 // Preserve the path structure of the files
archive1.PreservePath = true;

// Include any subdirectories
archive1.IncludeSubs = true;

// Exclude any text files
archive1.ExcludePattern = "*.txt";

// Set to use encryption
archive1.DefaultEncryption = Encryption.Standard;

// Specify the password
archive1.Password = "testme";

// Create a stream
System.IO.MemoryStream stream = new System.IO.MemoryStream();

// QuickZip to the stream
archive1.QuickZip("c:\\Test\\*.*", stream);

MessageBox.Show("The size of the compressed stream is " + stream.Length.ToString() + " bytes.");
See Also

Reference

Archive Class
Archive Members
Overload List


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