XAR extraction

Overview

Xar is popular Mac OS archiving format. You can extract such an archive with Aspose.Zip similarly as other archives.

Aspose.Zip can extract XAR entries compressed with gzip, bzip2, lzma.

Extract an Entry

Following sample extracts entries of the archive one by one.

 1if (!Directory.Exists("C:\\extracted"))
 2{
 3    Directory.CreateDirectory("C:\\extracted");
 4}
 5
 6using(XarArchive xarArchive =  new XarArchive("data.xar"))
 7{
 8    foreach (XarEntry entry in xarArchive.Entries) 
 9    {
10        if (entry is XarFileEntry xarFileEntry)
11        {
12            var entryPath = Path.Combine("C:\\extracted", entry.FullPath);
13            xarFileEntry.Extract(entryPath);
14        }
15        else if (entry is XarDirectoryEntry)
16        {
17            var entryPath = Path.Combine("C:\\extracted", entry.FullPath);
18            Directory.CreateDirectory(entryPath);
19        }
20    }
21}

Extract Whole Arcive

Following sample extracts all content to the directory.

1using (XarArchive xarArchive = new XarArchive("data.xar"))
2{
3    xarArchive.ExtractToDirectory("data");
4}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.