Initializes a new instance of the ZipArchive class.
[Visual Basic]
Public Sub New( _
licenseCode As String _
)
[C#]
public ZipArchive(
string licenseCode
);
[C++]
public: ZipArchive(
String* licenseCode
);
[JScript]
public function ZipArchive(
licenseCode : String
);
Parameters
Example
[Visual Basic, C#, C++] The following example demonstrates how to compress/decompress file with EACompression Zip Component. Events are not shown here, please refer to Samples section to get the full samples of EACompression.
[Visual Basic]
Imports EACompression
Sub Unzip()
Try
Dim oZip As New ZipArchive("TryIt")
oZip.Load("c:\test.zip")
Dim zs() As ZipFile = oZip.Files
Dim count As Integer = zs.Length
Dim password As String = ""
Dim overwrite As Boolean = True
For i As Integer = 0 To count - 1
Dim z As ZipFile = zs(i)
oZip.ExtractTo(z, password, "c:\unzipped", overwrite)
Next
'another way is:
'oZip.ExtractAll( "c:\uuzipped", password )
'if you want to remove one of the file from this zip archive.
'oZip.Remove( zs(0) )
Catch ep As Exception
Console.Write(ep.Message)
End Try
End Sub
Sub Zip()
Try
Dim oZip As New ZipArchive("TryIt")
oZip.Create("c:\test.zip", True) 'create a new zip file
Dim password As String = ""
'add a single file to zip file.
oZip.AddFile("c:\test.gif", "test.gif", password)
'add all files and sub-directory in temp folder to zip archive
oZip.AddDirectory("c:\temp", password)
Catch ep As Exception
Console.Write(ep.Message)
End Try
End Sub
[C#]
using System;
using System.Collections;
using EACompression;
void Unzip( )
{
try
{
ZipArchive oZip = new ZipArchive( "TryIt" );
oZip.Load( "c:\\test.zip" );
ZipFile [] zs = oZip.Files;
int count = zs.Length;
string password = "";
bool overwrite = true;
for( int i = 0; i < count; i++ )
{
ZipFile z = zs[i];
oZip.ExtractTo( z, password, "c:\\unzipped", overwrite );
}
//another way is:
//oZip.ExtractAll( "c:\\uuzipped", password );
//if you want to remove one of the file from this zip archive.
//oZip.Remove( zs[0] );
}
catch( Exception ep )
{
Console.Write( ep.Message );
}
}
void Zip()
{
try
{
ZipArchive oZip = new ZipArchive( "TryIt" );
oZip.Create( "c:\\test.zip", true ); //create a new zip file;
string password = "";
//add a single file to zip file.
oZip.AddFile( "c:\\test.gif", "test.gif", password );
//add all files and sub-directory in temp folder to zip archive
oZip.AddDirectory( "c:\\temp", password );
}
catch( Exception ep )
{
Console.Write( ep.Message );
}
}
[C++]
using namespace System;
using namespace System::Collections;
using namespace EACompression;
void Unzip( )
{
try
{
ZipArchive *oZip = new ZipArchive( S"TryIt" );
oZip->Load( S"c:\\test.zip" );
ZipFile *zs[] = oZip->Files;
int count = zs->Length;
String *password = S"";
bool overwrite = true;
for( int i = 0; i < count; i++ )
{
ZipFile *z = zs[i];
oZip->ExtractTo( z, password, S"c:\\unzipped", overwrite );
}
//another way is:
//oZip->ExtractAll( S"c:\\uuzipped", password );
//if you want to remove one of the file from this zip archive.
//oZip->Remove( zs[0] );
}
catch( Exception *ep )
{
Console::Write( ep->Message );
}
}
void Zip()
{
try
{
ZipArchive *oZip = new ZipArchive( S"TryIt" );
oZip->Create( S"c:\\test.zip", true ); //create a zip file;
String *password = S"";
//add a single file to zip file.
oZip->AddFile( S"c:\\test.gif", S"test.gif", password );
//add all files and sub-directory in temp folder to zip archive
oZip->AddDirectory( S"c:\\temp", password );
}
catch( Exception *ep )
{
Console::Write( ep->Message );
}
}