IZipArchive Interface

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

Members

Name Description
Method AddFile Compresses a file and adds it to the archive.
Method CloseArchive Closes the archive.
Method CreateArchive Creates a new archive.
Method Extract Extracts all items in the archive to the output directory.
Method ExtractFile Extracts a file from the archive to the output directory.
Method GetFileNames Obtains the list of files in the archive.
Method OpenArchive Opens an existing archive.

IZipArchive.AddFile Method

Compresses a file and adds it to the archive.

Public Sub AddFile ( _
    ByVal inputFile As String _
)
public void AddFile (
    string inputFile
);

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.

IZipArchive.CloseArchive Method

Closes the archive.

Public Sub CloseArchive ( _
)
public void CloseArchive (
);

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.

IZipArchive.CreateArchive Method

Creates a new archive.

Public Sub CreateArchive ( _
    ByVal archiveName As String _
)
public void CreateArchive (
    string archiveName
);

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.

IZipArchive.Extract Method

Extracts all items in the archive to the output directory.

Public Sub Extract ( _
    ByVal outputDir As String _
)
public void Extract (
    string outputDir
);

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.

IZipArchive.ExtractFile Method

Extracts a file from the archive to the output directory.

Public Sub ExtractFile ( _
    ByVal file As String, _
    ByVal outputDir As String _
)
public void ExtractFile (
    string file,
    string outputDir
);

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.

IZipArchive.GetFileNames Method

Obtains the list of files in the archive.

Public Function GetFileNames ( _
) As IEnumBSTR
public IEnumBSTR GetFileNames (
);

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.

IZipArchive.OpenArchive Method

Opens an existing archive.

Public Sub OpenArchive ( _
    ByVal archiveName As String _
)
public void OpenArchive (
    string archiveName
);

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.

Classes that implement IZipArchive

Classes Description
ZipArchive The ZipArchive object which manages zip archives.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.