Actually, I find that this code works better then the answer.
Well, this was not properly documented anywhere on the Internet. There were some possibilities, but they wouldn't calculate properly. This is a working Progress percentage calculation for decompressing archives in SharpCompress.
This is taken from my Decompression Class, so there is extra information in the logic. However, what is important is casting the 'CompressedBytesRead' to double, and dividing it into the total size of the archive which should also be cast to double.
`
public static double Percentage {get; set;}
public static long totalSize { get; set; }
public static void BeginDecompression(string fullFileName, string fileName)
{
try
{
var settings = new Configuration().GetSettings();
CurrentExtractionName = (Path.GetFileNameWithoutExtension(fileName));
StringHelpers.ItemInfo item = StringHelpers.GetItemInfo(fileName);
string extractPath = settings.EmbyAutoOrganizeFolderPath + "\\" +
(Path.GetFileNameWithoutExtension(fileName));
Directory.CreateDirectory(extractPath);
IArchive archive = ArchiveFactory.Open(fullFileName);
// Calculate the total extraction size.
totalSize = archive.TotalSize;
Console.WriteLine(totalSize);
foreach (IArchiveEntry entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
archive.EntryExtractionEnd += FileMoveSuccess;
archive.CompressedBytesRead += Archive_CompressedBytesRead;
entry.WriteToDirectory(extractPath, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
private static void Archive_CompressedBytesRead(object sender, CompressedBytesReadEventArgs e)
{
Percentage = ((double)e.CompressedBytesRead / (double)totalSize) * 100;
Console.WriteLine(Percentage);
}
`
If anyone has something better, I'm all ears, but this will work to implement a progress bar.