Пример #1
0
        private void ZipFolder_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(DirectoryPath.Text))
            {
                WinForms.MessageBox.Show("Please select your folder.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DirectoryPath.Focus();
                return;
            }

            string path = DirectoryPath.Text;

            Thread thread = new Thread(t =>
            {
                using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
                {
                    zip.AddDirectory(path);
                    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
                    zip.SaveProgress          += Zip_SaveProgress;
                    zip.Save(string.Format($"{di.Parent.FullName}{di.Name}.zip"));
                }
            })
            {
                IsBackground = true
            };

            thread.Start();
        }