Answers for "save file tar.gz c#"

C#
1

files tar.gz

tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
Posted by: Guest on January-25-2020
0

save file tar.gz c#

//Perhaps the most popular package in NuGet that supports TAR is SharpZipLib. 
//Its wiki includes examples for working with tar.gz files, including creation. 
//The linked example archives an entire folder.
//To archive a single file, the sample can be simplified to this:
private void CreateTarGZ(string tgzFilename, string fileName)
{
    using (var outStream = File.Create(tgzFilename))
    using (var gzoStream = new GZipOutputStream(outStream))
    using (var tarArchive = TarArchive.CreateOutputTarArchive(gzoStream))
    {
        tarArchive.RootPath = Path.GetDirectoryName(fileName);

        var tarEntry = TarEntry.CreateEntryFromFile(fileName);
        tarEntry.Name = Path.GetFileName(fileName);

        tarArchive.WriteEntry(tarEntry,true);
    }
}
Posted by: Guest on October-18-2021

C# Answers by Framework

Browse Popular Code Answers by Language