ME3Explorer.PCCRepack.buttonCompressPCC_Click C# (CSharp) Method

buttonCompressPCC_Click() private method

private buttonCompressPCC_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void buttonCompressPCC_Click(object sender, EventArgs e)
        {
            if (openPccDialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = openPccDialog.FileName;
                string backupFile = fileName + ".bak";
                if (File.Exists(fileName))
                {
                    try
                    {
                        using (ME3Package pccObj = MEPackageHandler.OpenME3Package(fileName))
                        {
                            if (!pccObj.CanReconstruct)
                            {
                                var res = MessageBox.Show("This file contains a SeekFreeShaderCache. Compressing will cause a crash when ME3 attempts to load this file.\n" +
                                    "Do you want to visit a forum thread with more information and a possible solution?",
                                    "I'm sorry, Dave. I'm afraid I can't do that.", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
                                if (res == DialogResult.Yes)
                                {
                                    System.Diagnostics.Process.Start("http://me3explorer.freeforums.org/research-how-to-turn-your-dlc-pcc-into-a-vanilla-one-t2264.html");
                                }
                                return;
                            }
                            DialogResult dialogResult = MessageBox.Show("Do you want to make a backup file?", "Make Backup", MessageBoxButtons.YesNo);
                            if (dialogResult == DialogResult.Yes)
                            {
                                File.Copy(fileName, backupFile);
                            }

                            pccObj.saveByReconstructing(fileName, true); 
                        }

                        MessageBox.Show("File " + Path.GetFileName(fileName) + " was successfully compressed.", "Succeed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show("An error occurred while compressing " + Path.GetFileName(fileName) + ":\n" + exc.Message, "Exception Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //recovering backup file
                        if (File.Exists(backupFile))
                        {
                            File.Delete(fileName);
                            File.Move(backupFile, fileName);
                        }
                    }
                }
            }
        }