📅  最后修改于: 2022-03-11 14:49:12.695000             🧑  作者: Mango
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);
}
}