static void extractAndCleanup()
{
if (System.IO.File.Exists(optionDownloadPath))
{
if (Path.GetExtension(optionDownloadPath).ToLower() != ".zip")
{
if (Path.GetFileNameWithoutExtension(optionDownloadPath).ToLower().StartsWith("avalonpatch"))
{
//Lets run it
if (File.Exists(optionDownloadPath))
{
ProcessStartInfo upgradeProcess = new ProcessStartInfo(optionDownloadPath);
upgradeProcess.WorkingDirectory = Path.GetDirectoryName(optionDownloadPath);
if (AvalonGUIConfig.patchUtilityRunUnattended)
upgradeProcess.Arguments = "/unattended ";
if (AvalonGUIConfig.patchUtilityRestartMP)
upgradeProcess.Arguments += "/restartconfiguration";
System.Diagnostics.Process.Start(upgradeProcess);
Application.Exit();
}
}
else
{
// Not a zip so can't process internally - download to desktop and set flag so we can inform the user to exit MP and manually install the update
System.IO.File.Copy(optionDownloadPath, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), Path.GetFileName(optionDownloadPath)), true);
System.IO.File.Delete(optionDownloadPath);
AvalonGUIConfig.manualInstallNeeded = true;
}
}
else
{
FastZip fz = new FastZip();
fz.ExtractZip(optionDownloadPath, destinationPath, "");
System.IO.File.Delete(optionDownloadPath);
AvalonGUIConfig.manualInstallNeeded = false;
// Now check what we have and copy to the right places.....
AvalonGUIConfig.checkAndCopy(destinationPath);
Directory.Delete(destinationPath, true);
}
}
pBar.Value = 0;
}