Pack and ProgressBar

Jun 3, 2012 at 8:48 AM

How to realise plainly I do not know (. Recently only has started to write on C#

Apr 10, 2014 at 11:37 AM
Here is some code I recently used that seems to do the job, not sure if it is the most efficient, wpf .net framework 4.5
private async void ZipIt(string src, string dest)
{
    await Task.Run(() =>
    {
        using (var zipFile = new ZipFile())
        {
            // add content to zip here 
            zipFile.AddDirectory(src);
            zipFile.SaveProgress +=
                (o, args) =>
                {
                    var percentage = (int)(1.0d / args.TotalBytesToTransfer * args.BytesTransferred * 100.0d);
                    // report your progress
                    pbCurrentFile.Dispatcher.Invoke(
                        System.Windows.Threading.DispatcherPriority.Normal,
                        new Action(
                        delegate()
                        {

                            pbCurrentFile.Value = percentage;
                        }
                        ));
                };
            zipFile.Save(dest);
        }
    });
}