/// <summary> /// Sets the working directory for the programme. /// </summary> /// <remarks> /// This sets the working directory to the Fallout 3 install folder. /// </remarks> /// <param name="p_strErrorMessage">The out parameter that is set to the error message, if an error occurred.</param> /// <returns> /// <lang langref="true" /> if the working directory was successfully set; /// <lang langref="false" /> otherwise. /// </returns> public override bool SetWorkingDirectory(out string p_strErrorMessage) { var strWorkingDirectory = Properties.Settings.Default.falloutNewVegasWorkingDirectory; if (String.IsNullOrEmpty(strWorkingDirectory) || !Directory.Exists(strWorkingDirectory)) { try { strWorkingDirectory = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Bethesda Softworks\FalloutNV", "Installed Path", null) as string; } catch { strWorkingDirectory = null; } } using (var wdfForm = new WorkingDirectorySelectionForm( "Could not find Fallout: New Vegas directory." + Environment.NewLine + "Fallout's registry entry appears to be missing or incorrect." + Environment.NewLine + "Please enter the path to your Fallout: New Vegas game file, or click \"Auto Detect\" to search" + " for the install directory. Note that Auto Detection can take several minutes.", "Fallout: New Vegas Game Directory:", new[] { "falloutNV.exe", "falloutNVng.exe" })) { while (!VerifyWorkingDirectory(strWorkingDirectory)) { if (wdfForm.ShowDialog() == DialogResult.Cancel) { p_strErrorMessage = "Could not find Fallout: New Vegas directory."; return(false); } strWorkingDirectory = wdfForm.WorkingDirectory; } } Directory.SetCurrentDirectory(strWorkingDirectory); Properties.Settings.Default.falloutNewVegasWorkingDirectory = strWorkingDirectory; Properties.Settings.Default.Save(); p_strErrorMessage = null; return(true); }
/// <summary> /// Sets the working directory for the programme. /// </summary> /// <remarks> /// This sets the working directory to the Fallout 3 install folder. /// </remarks> /// <param name="p_strErrorMessage">The out parameter that is set to the error message, if an error occurred.</param> /// <returns> /// <lang langref="true" /> if the working directory was successfully set; /// <lang langref="false" /> otherwise. /// </returns> public override bool SetWorkingDirectory(out string p_strErrorMessage) { var strWorkingDirectory = Properties.Settings.Default.falloutNewVegasWorkingDirectory; if (String.IsNullOrEmpty(strWorkingDirectory) || !Directory.Exists(strWorkingDirectory)) { try { strWorkingDirectory = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\Bethesda Softworks\FalloutNV", "Installed Path", null) as string; } catch { strWorkingDirectory = null; } } using (var wdfForm = new WorkingDirectorySelectionForm( "Could not find Fallout: New Vegas directory." + Environment.NewLine + "Fallout's registry entry appears to be missing or incorrect." + Environment.NewLine + "Please enter the path to your Fallout: New Vegas game file, or click \"Auto Detect\" to search" + " for the install directory. Note that Auto Detection can take several minutes.", "Fallout: New Vegas Game Directory:", new[] { "falloutNV.exe", "falloutNVng.exe" })) { while (!VerifyWorkingDirectory(strWorkingDirectory)) { if (wdfForm.ShowDialog() == DialogResult.Cancel) { p_strErrorMessage = "Could not find Fallout: New Vegas directory."; return false; } strWorkingDirectory = wdfForm.WorkingDirectory; } } Directory.SetCurrentDirectory(strWorkingDirectory); Properties.Settings.Default.falloutNewVegasWorkingDirectory = strWorkingDirectory; Properties.Settings.Default.Save(); p_strErrorMessage = null; return true; }