I am trying to extract a .tgz file from my C# project, and I tried following the answers to this question:
However, this code example does not work for me:
using (Stream stream = File.OpenRead(tarPath))
{
var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
reader.WriteEntryToDirectory(extractPath, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
}
I get two errors:
1) ExtractOptions "does not exist in the current context". I am successfully using System.IO and SharpCompress.Readers, but I fail to find where ExtractOptions is located.
2) File "is a method, which is not valid in the given context". I have no idea why this happens!
In case it helps, I can successfully extract .zip files from the same path with a simple:
System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, extractPath);
If there is a better way to extract the .tgz file that would also help!
Thanks