SHAR Archive Composition

Contents
[ Hide Show ]

Overview

SHAR (Shell Archive) is a format that creates a shell script archive, typically used on Unix-based systems. While it’s an outdated format, it can still be useful in certain scenarios, such as sharing files across Unix environments. SHAR archives contain the commands necessary to extract files on a Unix system by executing the archive as a script. You can get more information about the SHAR archive in this article.

With Aspose.ZIP, you can create SHAR archives just like you would with other archive formats, such as ZIP or 7z. The process is simple and follows the same pattern of creating entries and saving the archive to a file.

In the example below, a SHAR archive is created with two files: alice.txt and block.raw. These files are added as entries to the SHAR archive and 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    }

shar is valid Unix shell script. This format is mostly outdated. However, you can compose such an archive with Aspose.Zip similarly as other archives.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.