With NetXtremeZipLite you can easily extract files inside an archive with only some lines of code, and this topic demonstrates how to extract files from an archive.
To extract files you need to open an archive by using Open method with FileMode parameter is Open. And you need to call Extract method of the NetXtremeZipLite class.
The sample code below shows you how to extract files:
| C# | Copy Code |
|---|---|
| using System; using System.Collections.Generic; using System.Text; using Safabyte; using Safabyte.ZipCore; namespace Sample { static class Extract { [STAThread] static void Main() { Extract("c:\\test.zip", "c:\\temp\\extracted", "test"); } private static void Extract(string fileName, string extractTo, string password) { NetXtremeZipLite zipLite = new NetXtremeZipLite(); zipLite.FileName = fileName; // Open the zip file. zipLite.Open(System.IO.FileMode.Open); zipLite.Password = password; zipLite.RootPath = extractTo; zipLite.Extract("*.*"); // Close the zip file. zipLite.Close(); } } } | |
| VB.NET | Copy Code |
|---|---|
| Imports System Imports System.Collections.Generic Imports System.Text Imports Safabyte Imports Safabyte.ZipCore Module Extract Sub Main() Extract("c:\test.zip", "c:\temp\extracted", "test") End Sub Private Sub Extract(ByVal fileName As String, ByVal extractTo As String, ByVal password As String) Dim zipLite As New NetXtremeZipLite() zipLite.FileName = fileName ' Create a new zip file. zipLite.Open(System.IO.FileMode.Open) zipLite.Password = password zipLite.RootPath = extractTo zipLite.Extract("*.*") ' Close the zip file. zipLite.Close() End Sub End Module | |


