コード例 #1
0
 private void SetWorkingFolder(string path)
 {
     using (_lock.Lock())
     {
         try
         {
             _factorio     = InstallationRepository.Create(Path.Combine(path, "game"));
             Installations = new ReactiveBindingList <InstallationSpec>(_factorio.EnumerateInstallations());
         }
         catch (ArgumentException)
         {
             Error = "I don't like that directory path :(";
         }
         catch (UnauthorizedAccessException)
         {
             Error = "Can not access the directory.";
         }
         catch (SecurityException)
         {
             Error = "Missing the required permission to access the folder.";
         }
         catch (PathTooLongException)
         {
             Error = "Directory path too long.";
         }
         catch (NotSupportedException)
         {
             Error = "File IO not supported on this system.";
         }
         catch (IOException)
         {
             Error = "The directory is actually a file or could not access the directory.";
         }
     }
 }
コード例 #2
0
        private async Task NewInstallHandler()
        {
            var specDialog = new InstallationSpecBuilderDialog();

            if (specDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            using (_lock.Lock())
            {
                try
                {
                    await Task.Run(() => _factorio.GetStandaloneInstallation(specDialog.SpecResult));

                    Installations.Clear();
                    Installations.AddRange(_factorio.EnumerateInstallations());
                }
                catch (UnauthorizedAccessException)
                {
                    Error = "Could not access the directory.";
                }
                catch (DirectoryNotFoundException)
                {
                    Error = "Invalid directory.";
                }
                catch (IOException)
                {
                    Error = "The path exists as a file, or is on an unmapped drive.";
                }
                catch (SecurityException)
                {
                    Error = "Not authorized to access the directory.";
                }
            }
        }