private static bool DownloadFileSync(NewProjectViewModel viewModel, string zipToUnpack, string fileToDownoad)
{
EmbeddedExecutableExtractor eee = EmbeddedExecutableExtractor.Self;
eee.ExtractFile("FlatRedBall.Tools.dll");
eee.ExtractFile("Ionic.Zip.dll");
eee.ExtractFile("Ionic.Zlib.dll");
string resultingLocation = eee.ExtractFile("FRBDKUpdater.exe");
UpdaterRuntimeSettings urs = new UpdaterRuntimeSettings();
urs.FileToDownload = fileToDownoad;
urs.FormTitle = "Downloading " + viewModel.ProjectType.FriendlyName;
if (string.IsNullOrEmpty(zipToUnpack))
{
throw new Exception("The zipToUnpack argument is null - it shouldn't be");
}
urs.LocationToSaveFile = zipToUnpack;
string whereToSaveSettings =
FileManager.UserApplicationDataForThisApplication + "DownloadInformation." + UpdaterRuntimeSettings.RuntimeSettingsExtension;
urs.Save(whereToSaveSettings);
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = resultingLocation;
// The username for the user may have a space in it
// so we need to have quotes around the path
psi.Arguments = "\"" + whereToSaveSettings + "\"";
Process process = Process.Start(psi);
while (!process.HasExited)
{
System.Threading.Thread.Sleep(200);
}
bool succeeded = process.ExitCode == 0;
return succeeded;
}