コード例 #1
0
 public static void InstallSwitch(string AppToInstall)
 {
     try
     {
         if (Properties.Settings.Default.Drive == String.Empty)
         {
             Core.ILogging.Output(true, false, false, false, "The Drive settings field has been left empty. Please configure this and try again.", true);
             MessageBox.Show("The Drive settings field has been left empty. Please configure this and try again.", "Error: No Drive set", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             Form Fs = new FmSelectSystem();
             Fs.Show();
             FmSelectSystem.SettingsActive = true;
             return;
         }
         Downloading             = true;
         PackageDownloadComplete = false;
         PackageProgress         = 0;
         Path = cd + "\\Data\\Cache\\Switch\\" + AppToInstall + ".zip";
         Uri URL = new Uri("https://www.switchbru.com/appstore/zips/" + AppToInstall + ".zip");
         CacheCheck.PerformCheck();
         URLStr = URL.ToString();
         GetPackage.DownloadProgressChanged += new DownloadProgressChangedEventHandler(PackageDownloadProgress);
         GetPackage.DownloadFileCompleted   += new AsyncCompletedEventHandler(PackageDownloadedAsync);
         GetPackage.DownloadFileAsync(URL, Path);
         return;
     }
     catch (Exception ex)
     {
         Core.ILogging.Output(true, false, false, false, ex.Message, true);
         MessageBox.Show(ex.Message + Environment.NewLine + "URL: " + URLStr, "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Installing  = false;
         Downloading = false;
         return;
     }
 }
コード例 #2
0
 private static async Task ExtractPackageAsync()
 {
     try
     {
         if (Properties.Settings.Default.Drive == null)
         {
             Core.ILogging.Output(true, false, false, false, "The Drive settings field has been left empty. Please configure this and try again.", true);
             MessageBox.Show("The drive letter has not been configured. Please do so, then try again.", "Error: Invalid Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             Form _UISettings = new FmSelectSystem();
             _UISettings.Show();
             FmSelectSystem.SettingsActive = true;
             return;
         }
         else
         {
             using (ZipFile Package = ZipFile.Read(Path))
             {
                 try
                 {
                     if (!File.Exists(cd + "\\Data\\Cache\\Cleanup.bat"))
                     {
                         File.WriteAllText(cd + "\\Data\\Cache\\Cleanup.bat", "@echo off \r\ndel \"" + Properties.Settings.Default.Drive + ":\\manifest.install.tmp\"" +
                                           "\r\ndel \"" + Properties.Settings.Default.Drive + ":\\info.json\"" +
                                           "\r\ndel \"" + Properties.Settings.Default.Drive + ":\\manifest.install\"" +
                                           "\r\ndel \"" + Properties.Settings.Default.Drive + ":\\info.json.tmp\"");
                         Process.Start(cd + "\\Data\\Cache\\Cleanup.bat");
                     }
                     else
                     {
                         Process.Start(cd + "\\Data\\Cache\\Cleanup.bat");
                     }
                 }
                 catch (Exception ex)
                 {
                     Core.ILogging.Output(true, false, false, false, ex.Message, true);
                     Failed = true;
                     return;
                 }
                 await Task.Run(() => Package.ExtractAll(Properties.Settings.Default.Drive + ":\\", ExtractExistingFileAction.OverwriteSilently));
             }
             if (Properties.Settings.Default.Clean == true)
             {
                 Directory.Delete(cd + "\\Data\\Cache\\Switch", true);
             }
             Installing = false;
             Installed  = true;
         }
     }
     catch
     {
         Installed  = true;
         Installing = false;
         return;
     }
     return;
 }