예제 #1
0
        private void UnProtectExcel(string fileName)
        {
            try
            {
                if (Directory.Exists(Path))
                {
                    Directory.Delete(Path, true);
                }

                ZipFile.ExtractToDirectory(fileName, Path);

                txtLog.Text += $"UnProtecting {System.IO.Path.GetFileNameWithoutExtension(fileName)} WorkBook" + Environment.NewLine;

                UnProtect(_pathWorkBook, "workbookProtection");

                UnProtectionSheets();

                if (!Directory.Exists(_archivePath))
                {
                    Directory.CreateDirectory(_archivePath);
                }
                ZipFile.CreateFromDirectory(Path, System.IO.Path.Combine(_archivePath, System.IO.Path.Combine(_archivePath, System.IO.Path.GetFileName(fileName))));

                txtLog.Text += "Done!" + Environment.NewLine;
            }
            catch (InvalidDataException e)
            {
                MessageBox.Error("This File is Not Supported");
                _exception = true;
            }
        }
예제 #2
0
 private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Error(e.Exception.ToString(), "全局异常");
     e.Handled = true;
 }