Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active January 13, 2022 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/b946bed04067591ae454630fd5b4a36c to your computer and use it in GitHub Desktop.
Save aspose-com-gists/b946bed04067591ae454630fd5b4a36c to your computer and use it in GitHub Desktop.
Convert ZIP Archives to TAR in C# .NET
// Load ZIP file
using (Archive source = new Archive("source.zip"))
{
// Create a TarArchive object for TAR archive
using (TarArchive tar = new TarArchive())
{
// Loop through entries
foreach (ArchiveEntry entry in source.Entries)
{
if (!entry.IsDirectory)
{
// Copy entry to TAR
MemoryStream mem = new MemoryStream();
entry.Open().CopyTo(mem);
tar.CreateEntry(entry.Name, mem);
}
}
// Save TAR archive
tar.Save("result.tar");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment