Learn how to convert ZIP archives to TAR format in C#: https://blog.aspose.com/2021/12/27/convert-zip-to-tar-in-csharp-net/
Last active
January 13, 2022 16:20
-
-
Save aspose-com-gists/b946bed04067591ae454630fd5b4a36c to your computer and use it in GitHub Desktop.
Convert ZIP Archives to TAR in C# .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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