Occurs when a file is being compressed to current zip file.
[Visual Basic]
Public Event OnCompressing As OnCompressingEventHandler
Public Delegate Sub OnCompressingEventHandler( _
ByVal sender As Object, _
ByVal z As ZipFile, _
ByVal compressed As Long, _
ByVal total As Long, _
ByRef cancel As Boolean _
)
[C#]
public event OnCompressingEventHandler OnCompressing;
public delegate void OnCompressingEventHandler(
object sender,
ZipFile z,
long compressed,
long total,
ref bool cancel
);
[C++]
public: __event OnCompressingEventHandler* OnCompressing;
public __gc __delegate void OnCompressingEventHandler(
Object* sender,
ZipFile* z,
__int64 compressed,
__int64 total,
bool __gc *cancel
);
Event Data
Remarks
Example
[Visual Basic, C#, C++] To get the complete samples of EACompression, please refer to Samples section.
[Visual Basic]
Imports EACompression
Imports System.IO
Module Module1
Sub Main()
Try
Dim oZip As New ZipArchive("TryIt")
oZip.Create("c:\test.zip", True) 'create a new zip file
AddHandler oZip.OnCompressing, AddressOf OnCompressing
Dim password As String = ""
'add a single file to zip file.
oZip.AddFile("c:\test.gif", "test.gif", password)
Catch ep As Exception
Console.Write(ep.Message)
End Try
End Sub
Sub OnCompressing( _
ByVal sender As Object, _
ByVal z As ZipFile, _
ByVal compressed As Long, _
ByVal total As Long, _
ByRef cancel As Boolean _
)
If compressed = 0 Then
Console.WriteLine("{0}", z.FullName)
Else
Console.WriteLine("{0}/{1}", compressed, total)
End If
End Sub
End Module
[C#]
using System;
using EACompression;
using System.IO;
namespace test
{
class Class1
{
public static void OnCompressing(
object sender,
ZipFile z,
long compressed,
long total,
ref bool cancel )
{
if( compressed == 0 )
{
Console.WriteLine( "{0}", z.FullName );
}
else
{
Console.WriteLine( "{0}/{1}", compressed, total );
}
}
[STAThread]
static void Main(string[] args)
{
try
{
ZipArchive oZip = new ZipArchive( "TryIt" );
oZip.Create( "c:\\test.zip", true ); //create a zip file;
oZip.OnCompressing += new ZipArchive.OnCompressingEventHandler( OnCompressing );
string password = "";
oZip.AddFile( "c:\\test.gif", "", password );
}
catch( Exception ep )
{
Console.Write( ep.Message );
}
}
}
}
[C++]
using namespace System;
using namespace System::IO;
using namespace EACompression;
public __gc class ZipArchiveEventHandler
{
public:
static void OnCompressing(
Object* sender,
ZipFile* z,
__int64 compressed,
__int64 total,
bool __gc *cancel
)
{
if( compressed == 0 )
Console::WriteLine( S"{0}", z->FullName );
else
Console::WriteLine( S"{0}/{1}", __box(compressed), __box(total));
}
};
int _tmain()
{
try
{
ZipArchive *oZip = new ZipArchive( S"TryIt" );
oZip->Create( S"c:\\test.zip", true ); //create a zip file;
oZip->OnCompressing += new ZipArchive::OnCompressingEventHandler( NULL, &ZipArchiveEventHandler::OnCompressing );
String *password = S"";
//add a single file to zip file.
oZip->AddFile( S"c:\\test.gif", S"test.gif", password );
}
catch( Exception *ep )
{
Console::Write( ep->Message );
}
return 0;
}