I'm trying to create a tar archive, then extract all the contents to a file using SharpZipLib. I am able to create the tar archive, but the program hangs when trying to extract it. I'm wondering if anyone else can reproduce this problem and see why it is happening. I've also tried using an example that allows for full control, and while debugging, it seems that my program hangs when tarIn.GetNextEntry()
is called.
Here is my code
public void CreateTarAndExtract()
{
// create tar file
string tarFile = "path_to_desktop\\tartest.tar";
string inputFolder = "path_to_desktop\\testfolder";
using (var output = File.OpenWrite(tarFile))
{
using (var archive = TarArchive.CreateOutputTarArchive(output, Encoding.UTF8))
{
var trimLength = inputFolder.Length + 1;
foreach (var fsEntry in Directory.GetFileSystemEntries(inputFolder, "*", SearchOption.AllDirectories))
{
var entry = TarEntry.CreateEntryFromFile(fsEntry);
entry.Name = fsEntry.Substring(trimLength);
archive.WriteEntry(entry, false);
}
}
}
// extract file
string outputPath = "path_to_desktop\\tartest";
using (var input = File.OpenRead(tarFile))
{
using (var archive = TarArchive.CreateInputTarArchive(input, Encoding.UTF8))
{
archive.ExtractContents(outputPath);
}
}
}