ZIP archiving format is well known and widely used to compress files and folders into a single compressed file. Whereas, TAR is another UNIX-based file format that offers the compression of various files into a single location. In fact, file compression is a must-have component in any online business because it reduces the file size and makes the file transfer fast over the internet. Most of the time, TAR is preferred as it retains permissions & provisions. In this blog post, we will learn how to convert ZIP to TAR in C# programmatically in a .NET application.
We will cover the following sections:
ZIP to TAR converter API installation
We will use this .NET ZIP library to programmatically achieve the ZIP to TAR conversion. It is a lightweight library used to compress & decompress various types of archive formats.
Convert ZIP to TAR in C# Programmatically
ZIP to TAR converter API offers methods and properties to convert ZIP format to TAR file format. However, you can go through the list of available methods here.
Follow the following steps to achieve this conversion:
- Instantiate an instance of the Archive class and load the source ZIP file.
- Create an object of the TarArchive class to access TAR features.
- Create an object of ArchiveEntry class to access each ArchiveEntry in the ZIP.
- Initialize an object of MemoryStream class and copy the entry using entry.Open().CopyTo(mem) method.
- Invoke the CreateEntry method to create a single entry within the TAR archive.
- Save the TAR file by calling the SaveGzipped method.
Copy and paste the following code snippet into your main file and run the server:
Get a Free License
You can avail a free temporary license to try the API without evaluation limitations.
We are ending this blog post here. We have implemented the process to convert ZIP to TAR in C# using this .NET ZIP library. Further, this article will surely help you if you want to integrate a ZIP to TAR conversion API in your .NET application. In addition, you can visit the documentation of this library to know about other methods and properties. Finally, conholdate.com is writing new blog posts on other topics. Therefore, please stay in touch for regular updates.
Ask a question
You can let us know about your questions or queries on our forum.