ZipArchive.Load Method


Loads an existed zip file to current object to operate.

[Visual Basic]
Public Sub Load( _
    fileName As String _
)

Public Sub Load( _
    s As Stream _
)
[C#]
public void Load(
    string fileName
);

public void Load(
    Stream s
);
[C++]
public: void Load(
    String* fileName
);

public: void Load(
    Stream* s
);
[JScript]
public function Load( 
    fileName: String
);

public function Load( 
    s: Stream
);

Parameters

file
The zip full file name to load.
s
A zip stream to load.

Example

[Visual Basic, C#, C++] The following example demonstrates how to compress/decompress file with EACompression Zip Component. This sample doesn't demonstrates the events, please refer to Samples section to get the complete samples of EACompression.

[Visual Basic]
Imports EACompression
Imports System.IO

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

        For i As Integer = 0 To count - 1
            Dim z As ZipFile = zs(i)
            Console.WriteLine("Name: {0}", z.Name)
            Console.WriteLine("FullName: {0}", z.FullName)
            Console.WriteLine("Size: {0}", z.Length)
            Console.WriteLine("Compressed Size:{0}", z.CompressedSize)
            Console.WriteLine("Encrypted: {0}", z.Encrypted)
            Console.WriteLine("Is Directory: {0}", z.IsDirectory)
            Console.WriteLine("Creation Time: {0}", z.CreationTime)
            Console.WriteLine("Last Write Time: {0}", z.LastWriteTime)
            Console.WriteLine("Last Access Time: {0}", z.LastAccessTime)
            Console.WriteLine("Attributes: {0}", z.Attributes)         
        Next
        
        //load zip file by stream           
        'Dim fs As New FileStream("c:\test.zip", FileMode.Open, FileAccess.ReadWrite)
        'oZip.Load( fs )
        '....
        'fs.Close() 
        
    Catch ep As Exception
        Console.Write(ep.Message)
    End Try
End Sub

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

void Unzip( )
{
    try
    {
        ZipArchive oZip = new ZipArchive( "TryIt" );
        oZip.Load( "c:\\test.zip" );

        ZipFile [] zs = oZip.Files;
        int count = zs.Length;
        
        for( int i = 0; i < count; i++ )
        {
            ZipFile z = zs[i];
            Console.WriteLine( "Name: {0}", z.Name );
            Console.WriteLine( "FullName: {0}", z.FullName );
            Console.WriteLine( "Size: {0}", z.Length );
            Console.WriteLine( "Compressed Size:{0}", z.CompressedSize );
            Console.WriteLine( "Encrypted: {0}", z.Encrypted );
            Console.WriteLine( "Is Directory: {0}", z.IsDirectory );
            Console.WriteLine( "Creation Time: {0}", z.CreationTime );
            Console.WriteLine( "Last Write Time: {0}", z.LastWriteTime );
            Console.WriteLine( "Last Access Time: {0}", z.LastAccessTime );
            Console.WriteLine( "Attributes: {0}", z.Attributes );
        }
        
        //create zip file by stream           
        //FileStream fs = new FileStream("c:\\test.zip", FileMode.Open, FileAccess.ReadWrite);
        //oZip.Load( fs );
        //...
        //fs.Close(); 
        
    }
    catch( Exception ep )
    {
        Console.Write( ep.Message );
    }
}

[C++]
using namespace System;
using namespace System::Collections;
using namespace System::IO;
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;

        for( int i = 0; i < count; i++ )
        {
            ZipFile *z = zs[i];
            Console::WriteLine( S"Name: {0}", z->Name);
            Console::WriteLine( S"FullName: {0}", z->FullName );
            Console::WriteLine( S"Size: {0}", __box(z->Length));
            Console::WriteLine( S"Compressed Size:{0}", __box(z->CompressedSize));
            Console::WriteLine( S"Encrypted: {0}", __box(z->Encrypted));
            Console::WriteLine( S"Is Directory: {0}", __box(z->IsDirectory));
            Console::WriteLine( S"Creation Time: {0}", __box(z->CreationTime));
            Console::WriteLine( S"Last Write Time: {0}", __box(z->LastWriteTime));
            Console::WriteLine( S"Last Access Time: {0}", __box(z->LastAccessTime));
            Console::WriteLine( S"Attributes: {0}", __box(z->Attributes));
        }
        
         //load zip file by stream 
        //FileStream *fs = new FileStream(S"c:\\test.zip", FileMode::Open, FileAccess::ReadWrite);
        //oZip->Load( fs );
        //....
        //fs->Close(); 
    }
    catch( Exception *ep )
    {
        Console::Write( ep->Message );
    }
}