ZipArchive.OnRemoving Event


Occurs when the object is loading a zip archive.

[Visual Basic]
Public Event OnRemoving As OnRemovingEventHandler
Public Delegate Sub OnRemovingEventHandler( _
    ByVal sender As Object, _
    ByVal z As ZipFile
)
[C#]
public event OnRemovingEventHandler OnRemoving;
public delegate void OnRemovingEventHandler( 
     object sender, 
     ZipFile z
);
[C++]
public: __event OnRemovingEventHandler* OnRemoving;
public __gc __delegate void OnRemovingEventHandler( 
     Object* sender, 
     ZipFile* z
);
[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 removed.

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.OnRemoving, AddressOf OnRemoving
            
            oZip.Load("c:\test.zip")
                    
            Dim zs() As ZipFile = oZip.Files
        
            'remove the first file
            If zs.Length > 0 Then
                oZip.Remove( zs(0) )
            End If
          
            'remove all files
            'oZip.Remove( zs )
            
        Catch ep As Exception
            Console.Write(ep.Message)
        End Try
    End Sub

    Sub OnRemoving( _
    ByVal sender As Object, _
    ByVal z As ZipFile _
)
        Console.WriteLine("{0}", z.FullName)
    End Sub
End Module

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

namespace test
{
    class Class1
    {
        public static void OnRemoving( 
            object sender, 
            ZipFile z )
        {
            Console.WriteLine( "{0}", z.FullName );
        }
        
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                ZipArchive oZip = new ZipArchive( "TryIt" );
                oZip.OnRemoving += new ZipArchive.OnRemovingEventHandler( OnRemoving );
                
                oZip.Load( "c:\\test.zip" );
                
                ZipFile [] zs = oZip.Files;
        
                // remove the first file
                if( zs.Length > 0 )
                    oZip.Remove( zs[0] );

                //remove all files
                //oZip.Remove( zs );
            
            }
            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 OnRemoving( 
        Object* sender, 
        ZipFile* z
    )
    {
        Console::WriteLine( S"{0}", z->FullName );
    }
};

int _tmain()
{
    try
    {
        ZipArchive *oZip = new ZipArchive( S"TryIt" );
        oZip->OnRemoving += new ZipArchive::OnRemovingEventHandler( NULL, &ZipArchiveEventHandler::OnRemoving );
        oZip->Load( S"c:\\test.zip" );
    
        ZipFile *zs[] = oZip->Files;
        // remove the first file
        if( zs->Length > 0 )
            oZip->Remove( zs[0] );

        //remove all files
        //oZip->Remove( zs );
    }
    catch( Exception *ep )
    {
        Console::Write( ep->Message );
    }
    return 0;
}