private void DeleteMods()
        {
            try
            {
                List <string> files;
                List <string> dirs;
                GameScanner.ListRootMods(out files, out dirs);
                List <string> dlc = GameScanner.ListDlcMods();

                this.SetBarMaximum(files.Count + dirs.Count + dlc.Count);

                foreach (string mod in files)
                {
                    IOUtils.Delete(mod);
                    this.IncrBarValue();
                }

                foreach (string dir in dirs)
                {
                    if (Directory.Exists(dir))
                    {
                        IOUtils.Delete(dir);
                    }
                    this.IncrBarValue();
                }

                foreach (string mod in dlc)
                {
                    IOUtils.Delete(mod);
                    this.IncrBarValue();
                }

                this.ClosePopup();
            }
            catch (IOException)
            {
                this.Dispatcher.Invoke(new Callback(RetryAfterPermissionUpgrade));
            }
            catch (UnauthorizedAccessException)
            {
                this.Dispatcher.Invoke(new Callback(RetryAfterPermissionUpgrade));
            }
        }
Exemplo n.º 2
0
        public override void Perform(WorkManager manager)
        {
            try
            {
                if (manager.ProgressDisplay is IJobDisplay)
                {
                    ((IJobDisplay)manager.ProgressDisplay).Description = I18n.Localize("Label", "DeletingMods");
                }

                GameScanner.ListRootMods(out List <string> files, out List <string> dirs);
                List <string> dlc = GameScanner.ListDlcMods();

                foreach (string mod in files)
                {
                    IOUtil.Delete(mod);
                }

                foreach (string dir in dirs)
                {
                    if (Directory.Exists(dir))
                    {
                        IOUtil.Delete(dir);
                    }
                }

                foreach (string mod in dlc)
                {
                    IOUtil.Delete(mod);
                }
            }
            catch (IOException e)
            {
                Log.Error(e.ToString());
                LocalizedMessage.Show(Launcher.Instance.Window, "ProfileSwitchError", "FatalError", DialogIcon.Error, DialogButtons.Ok);
                Process.GetCurrentProcess().Kill();
            }
        }