ZipArchive.SaveAs Method


Saves current zip file to other location.

[Visual Basic]
Public Sub SaveAs( _
    fileName As String, _
    overwrite As Boolean _
)

[C#]
public void SaveAs(
    string fileName,
    bool overwrite
);

[C++]
public: void SaveAs(
    String* fileName,
    bool overwrite
);

[JScript]
public function SaveAs( 
    fileName: String,
    overwrite: Boolean
);

Parameters

file
The new zip file name to save.
overwrite
A boolean value indicates whether this method overwrites the file if the file already exists.

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 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", "", password)
      
        oZip.SaveAs( "c:\test1.zip", True )
      
    Catch ep As Exception
        Console.Write(ep.Message)
    End Try
End Sub

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

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", "", password );  
        
        oZip.SaveAs( "c:\\test1.zip", true );
    }
    catch( Exception ep )
    {
        Console.Write( ep.Message );
    }
}

[C++]
using namespace System;
using namespace System::Collections;
using namespace System::IO;
using namespace EACompression; 

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"", password );
        
        oZip->SaveAs( S"c:\\test1.zip", true );     
    }
    catch( Exception *ep )
    {
        Console::Write( ep->Message );
    }
}