ZipArchive.OnLoading Event


Occurs when the object is loading a zip archive.

[Visual Basic]
Public Event OnLoading As OnLoadingEventHandler
Public Delegate Sub OnLoadingEventHandler( _
    ByVal sender As Object, _
    ByVal z As ZipFile, _
    ByVal loaded As Long, _
    ByVal total As Long, _
    ByRef cancel As Boolean _
)
[C#]
public event OnLoadingEventHandler OnLoading;
public delegate void OnLoadingEventHandler( 
     object sender, 
     ZipFile z,
     long loaded,
     long total,
     ref bool cancel 
);
[C++]
public: __event OnLoadingEventHandler* OnLoading;
public __gc __delegate void OnLoadingEventHandler( 
     Object* sender, 
     ZipFile* z,
     __int64 loaded,
     __int64 total,
     bool __gc *cancel 
);
[JScript] In JScript, you can handle the events defined by a class. However, you cannot define your own.

Event Data

sender
The source (ZipArchive instance) of the event.
z
The (ZipFile instance) being loaded.
loaded
The number of files loaded.
total
The number of files in current zip archive.
cancel
Gets or sets a value indicating whether the task should be canceled.

Remarks

If cancel parameter is set to true in the event, the client terminates the task immediately and a UserTerminatedException exception will be thrown.

Example

[Visual Basic, C#, C++] To get the full 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")
            AddHandler oZip.OnLoading, AddressOf OnLoading
            
            oZip.Load("c:\test.zip")
            Dim password As String = ""
            oZip.ExtractAll( "c:\unzipped", password )
            
        Catch ep As Exception
            Console.Write(ep.Message)
        End Try
    End Sub

    Sub OnLoading( _
    ByVal sender As Object, _
    ByVal z As ZipFile, _
    ByVal loaded As Long, _
    ByVal total As Long, _
    ByRef cancel As Boolean _
)
        Console.WriteLine("{0}", z.FullName)
    End Sub
End Module

[C#]
using System;
using EACompression;
using System.IO;

namespace test
{
    class Class1
    {
        public static void OnLoading( 
            object sender, 
            ZipFile z, 
            long loaded, 
            long total, 
            ref bool cancel )
        {
            Console.WriteLine( "{0}", z.FullName );
        }
        
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                ZipArchive oZip = new ZipArchive( "TryIt" );
                oZip.OnLoading += new ZipArchive.OnLoadingEventHandler( OnLoading );
                
                oZip.Load( "c:\\test.zip" );
                string password = "";
                oZip.ExtractAll( "c:\\unzipped", 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 OnLoading( 
        Object* sender, 
        ZipFile* z,
        __int64 loaded,
        __int64 total,
        bool __gc *cancel 
    )
    {
        Console::WriteLine( S"{0}", z->FullName );
    }
};

int _tmain()
{
    try
    {
       ZipArchive *oZip = new ZipArchive( S"TryIt" );
       oZip->OnLoading += new ZipArchive::OnLoadingEventHandler( NULL, &ZipArchiveEventHandler::OnLoading );
       oZip->Load( S"c:\\test.zip" );
    
        String *password = S"";
        oZip->ExtractAll( S"c:\\uuzipped", password );
    }
    catch( Exception *ep )
    {
        Console::Write( ep->Message );
    }
    return 0;
}