What different between TGZ format and TAR.GZ format?
TGZ with TAR.GZ is the sameWhat is SharpCompress?
SharpCompress is a compression library for .NET/Mono/Silverlight/WP7, WP8, WP8.1/WindowsStore that can unrar decompress RAR, 7zip, zip/unzip, tar/untar bzip2/unbzip2 and gzip with forward-only reading and file random access APIs.Write support for zip/tar/bzip2/gzip is implemented.
The following are not yet supported,
- RAR 5
- Write 7Zip
- Zip64
- Multi-volume Zip
Explore My Other Channel for More Cool and Valuable Insights
π Youtube Learn Tech Tipsπ Tiktok
π Facebook:How to work?
Install SharpCompress
To install SharpCompress, you can manually fork the repository from Github. Or you can use NuGetInclude Library
Source Code:
using SharpCompress.Reader;
using SharpCompress.Common;
	How to decompress tgz, tar.gz by using SharpCompress library
static void Main(string[] args)
	{
		unTAR(@"E:\test\server.tgz");
		Console.WriteLine("Decompress Succeed!");
		Console.ReadLine();
	}
	
	private static string directoryPath = @"E:\test\extract";
	
	static void unTAR(string tarFilePath)
	{            
		// UTF7: support chinese font -> UTF.7
		SharpCompress.Common.ArchiveEncoding.Default = Encoding.UTF7;
	
		using (Stream stream = File.OpenRead(tarFilePath))
		{            
			var reader = ReaderFactory.Open(stream);
					
			while (reader.MoveToNextEntry())
			{
				if (!reader.Entry.IsDirectory)
					reader.WriteEntryToDirectory(directoryPath, 
					   ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
	
			}
		 }
	}
	
	Before and after decompress from server.tgz file
E:\test\server.tgzYou can download full source code from here
Are you interested in topic EXTRACT TGZ, TAR.GZ unzip a tgz BY SHARPCOMPRESS C# from Webzone Tech Tips? If you have any thoughts or questions, please share them in the comment section below. I would love to hear from you and chat about it
Webzone Tech Tips Zidane
 
 
 
 
 
 
 
 



 
 
 
 
 
 
 
 
 
 
