How to Convert CAB to ZIP Using C#
In order to convert CAB to ZIP, we’ll use
API which is a feature-rich, powerful and easy to use archive conversion API for C# platform. Open
package manager, search for Aspose.ZIP and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Zip
Steps to Convert CAB to ZIP via C#
Convertation from one archive format to another consist of following steps:
- Extract archive to intermediate storage
- Compress extracted data to desired format
System Requirements
Before running the conversion example code, make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with .NET Framework, Mono and COM Interop.
- Development environment like Microsoft Visual Studio.
- Aspose.ZIP for .NET DLL referenced in your project.
Sample code to convert from CAB to ZIP
Code from CAB to various formats. The CAB archive contains several records, and the GZ, LZ, Z, XZ, BZ2 formats compress one source. Therefore, compression into these formats is done by packaging first into a TAR archive, which is typical for Linux.
Convert from CAB to ZIP - C#
using (Archive zip = new Archive())
{
using (CabArchive cabArchive = new CabArchive("archive.cab"))
{
for (int i = 0; i < cabArchive.Entries.Count; i++)
{
var ms = new MemoryStream();
cabArchive.Entries[i].Extract(ms);
ms.Seek(0, SeekOrigin.Begin);
zip.CreateEntry(cabArchive.Entries[i].Name, ms);
}
}
zip.Save("output.zip");
}
Free App to Convert CAB to ZIP
Check our live demos for CAB to ZIP conversion with following benefits.
Other Supported Conversions
You can also convert CAB into many other file formats including few listed below.