Create TAR
Tar, which stands for "Tape Archive," is a file archiving format and utility commonly used in Unix and Linux systems. It allows users to bundle multiple files and directories into a single archive without compression, effectively preserving the file structure and metadata. Tar is often used in conjunction with compression utilities like gTar or bTar2 to create compressed archives, which are frequently utilized for data backups and software distribution.
With IronZip, we can easily automate these processes to mitigate human errors and significantly improve efficiency, making the entire workflow more practical and manageable.
The 5 Steps to Creating TAR File with C#
- using IronZip;
- using (var archive = new IronTarArchive())
- archive.Add("./assets/image1.jpg");
- archive.Add("./assets/example.pdf");
- archive.SaveAs("output.tar");
Creating an Empty Tar Archive
Initially, we import the IronZip
namespace to access the library. Next, we create a new Tar archive by utilizing the IronTarArchive
constructor within a using
statement, which sets up an empty Tar archive.
Adding Files to the Empty Archive
Before finalizing the save, we can include files using the Add
method by supplying their absolute paths. You have the option to add either single or multiple files to the archive. The types of files you can incorporate range from images and documents (like docx and PDF) to audio files (such as MP3 and WAV), and even Tar archives, allowing you to create a compressed archive within another archive.
For more information regarding the list of compatible files that you can add, please refer to the documentation here.
Saving and Exporting it
We finally save the archive and export it using the SaveAs
method, saving it as output.tar
.