com.esri.arcgis.system
Interface IZipArchive

All Superinterfaces:
Serializable
All Known Implementing Classes:
ZipArchive

public interface IZipArchive
extends Serializable

Provides access to methods and properties to create and manage zip archives.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


Method Summary
 void addFile(String inputFile)
          Compresses a file and adds it to the archive.
 void closeArchive()
          Closes the archive.
 void createArchive(String archiveName)
          Creates a new archive.
 void extract(String outputDir)
          Extracts all items in the archive to the output directory.
 void extractFile(String file, String outputDir)
          Extracts a file from the archive to the output directory.
 IEnumBSTR getFileNames()
          Obtains the list of files in the archive.
 void openArchive(String archiveName)
          Opens an existing archive.
 

Method Detail

openArchive

void openArchive(String archiveName)
                 throws IOException,
                        AutomationException
Opens an existing archive.

Description

Opens an existing zip archive with the specified file name.

Ensure the zip archive you want to open is not empty, as OpenArchive method would fail if the archive doesn't contain anything in it.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
archiveName - The archiveName (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

createArchive

void createArchive(String archiveName)
                   throws IOException,
                          AutomationException
Creates a new archive.

Description

Creates a new zip archive with the specified file name. The file name must include the zip extension (*.zip).

If a zip archive with the specified file name already exists it will automatically be replaced with a new empty zip archive and the contents of the previous zip archive will be lost.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
archiveName - The archiveName (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

closeArchive

void closeArchive()
                  throws IOException,
                         AutomationException
Closes the archive.

Description

Closes the zip archive. In order to open an archive use either the CreateArchive (create a new archive) or OpenArchive (open existing one) methods.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

addFile

void addFile(String inputFile)
             throws IOException,
                    AutomationException
Compresses a file and adds it to the archive.

Description

Compresses and adds the specified file to the zip archive. Ensure the zip archive is open before using the AddFile method by either using the CreateArchive (if you just created an archive) or OpenArchive (if you are using a previously created archive) methods.

Note, you cannot use the AddFile method to add the contents of a directory to a zip archive.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
inputFile - The inputFile (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getFileNames

IEnumBSTR getFileNames()
                       throws IOException,
                              AutomationException
Obtains the list of files in the archive.

Description

Returns an enumeration of file names in the zip archive. Ensure the zip archive is open before using the GetFileNames method by using the OpenArchive method.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Returns:
A reference to a com.esri.arcgis.system.IEnumBSTR
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

extractFile

void extractFile(String file,
                 String outputDir)
                 throws IOException,
                        AutomationException
Extracts a file from the archive to the output directory.

Description

The ExtractFile method extracts the specified compressed file in the zip archive into the specified directory. Use the GetFileNames method to return an enumeration of files in the zip archive. Ensure the zip archive is open before using the ExtractFile method by using the OpenArchive method.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
file - The file (in)
outputDir - The outputDir (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

extract

void extract(String outputDir)
             throws IOException,
                    AutomationException
Extracts all items in the archive to the output directory.

Description

The Extract method extracts all of the compressed files in the zip archive into the specified directory. Ensure the zip archive is open before using the Extract method by using the OpenArchive method.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
outputDir - The outputDir (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.