Learn how to compress TAR files and create TAR.GZ and TAR.XZ files in C#: https://blog.aspose.com/2022/01/05/create-tar-gz-xz-files-in-csharp/
Last active
January 6, 2022 03:29
-
-
Save aspose-com-gists/7d70833d03a4a84b810f2b641c30547d to your computer and use it in GitHub Desktop.
Create TAR.GZ and TAR.XZ Files 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
// Create TAR archive | |
using (var archive = new TarArchive()) | |
{ | |
// Add files to archive | |
archive.CreateEntry("text.txt", @"D:\texts\article.txt"); | |
archive.CreateEntry("picture.png", @"D:\Picture\photo.png"); | |
// Compress TAR into tar.gz file | |
archive.SaveGzipped("result.tar.gz"); | |
} |
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
// Create a tar.xz file | |
using (FileStream xzFile = File.Open("archive.tar.xz", FileMode.Create)) | |
{ | |
// Create TAR archive | |
using (var archive = new TarArchive()) | |
{ | |
// Add files to archive | |
archive.CreateEntry("text.txt", @"D:\texts\article.txt"); | |
archive.CreateEntry("picture.png", @"D:\Picture\photo.png"); | |
// Compress TAR into tar.xz file | |
archive.SaveXzCompressed(xzFile); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment