SHAR Archive Composition

Contents
[ Hide Show ]

Overview

SHAR (Shell Archive) is a format that creates shell script archives, most commonly used on Unix-based systems. While this format is considered outdated, it can still be useful for sharing files across Unix environments. A SHAR archive contains all the commands necessary to extract its files simply by executing the archive as a standard shell script. For more details, see this article.

A SHAR archive is a valid Unix shell script.

With Aspose.ZIP, you can create SHAR archives just as you would with other formats like ZIP or 7z. The process is straightforward: create entries, then save the archive to a file.

The following example creates a SHAR archive containing two files: alice.txt and block.raw. These files are added as entries to the SHAR archive, which is then saved as result.shar.

1    using (var archive = new SharArchive())
2    {
3        archive.CreateEntry("alice.txt", File.OpenRead("alice.txt"));
4        archive.CreateEntry("data.bin", File.OpenRead("block.raw"));
5        archive.Save("result.shar");
6    }
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.