Create Executable Self-extracting Archive in C#

A self-extracting archive (SFX or SEA) is a special type of file that contains compressed data along with executable instructions. This archive has the ability to extract the files it contains by itself. Therefore, you don’t need any specific extractor or decompressor application to open self-extracting archives. In this article, you will learn how to create executable self-extracting archives in C# from within your .NET applications.

C# .NET API to Create Self-extracting Archives

To create self-extracting archives, we will use Aspose.ZIP for .NET. It is a powerful and feature-rich API that lets you automate the archiving features in .NET applications quite easily. Moreover, it supports a variety of popular archive formats such as ZIP, TAR, etc. You can download the API’s DLL or install it using NuGet.

PM> Install-Package Aspose.Zip 

Create a Self-extracting Archive in C#

Let’s start creating a self-extracting archive assuming that you have installed Aspose.ZIP for .NET. Since this will be an executable archive, its extension will be .exe. The following are the steps to create an executable self-extracting archive in C#.

The following code sample shows how to create an executable self-extracting archive in .NET.

Executing Self-extracting Archives using Command Line

The self-extracting archive that we have created in the previous section can be extracted by double-clicking it. However, if you want to use the command line, you can extract the archive with the following command.

C:>archive.exe -autoExtract 

Here, -autoExtract is the primary option that lets you extract the archive. In case the archive is password-protected, you can specify the password using -password option, as shown in the following command.

C:>archive.exe -autoExtract -password:T0p$ecret

The complete list of the commands to work with an executable self-extracting archive is provided in this article.

Get a Free API License

You can use Aspose.ZIP for .NET without evaluation limitations by getting a free temporary license.


In this article, you have learned how to create self-extracting archives (SFX or SEA) in C#. Furthermore, we have discussed how to extract a self-extracting archive using the command line. You can simply install Aspose.ZIP for .NET and embed the provided code sample in your .NET applications. Besides, you can explore more about Aspose.ZIP for .NET using its documentation. Also, you can post your queries to our forum.

See Also