/// <summary> /// Attempt to detect executable on the file-system at the following locations: /// - current directory; then /// - default installation paths; then /// - windows registry; then /// - hxe installation path /// </summary> /// <returns> /// Executable object if found. /// </returns> /// <exception cref="FileNotFoundException"> /// Executable has not been found on the file-system. /// </exception> public static Executable Detect() { var hce = Detection.Infer(); string fullName = ""; try { fullName = hce.FullName; } catch (System.Exception e) { var log = (File)Paths.Exception; log.AppendAllText("The inferred executable path was probably malformed or incomplete.\n Error: " + e + "\n"); using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog()) { ofd.InitialDirectory = GetFolderPath(SpecialFolder.Desktop); ofd.Filter = "Halo Custom Edition (haloce.exe)|haloce.exe|Halo Retail/Trial (halo.exe)|halo.exe"; ofd.FilterIndex = 1; ofd.RestoreDirectory = true; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fullName = GetFullPath(ofd.FileName); } } } if (System.IO.File.Exists(fullName)) { return((Executable)fullName); } throw new FileNotFoundException("Could not detect executable on the filesystem."); }
/// <summary> /// Attempt to detect executable on the file-system at the following locations: /// - current directory; then /// - default installation paths; then /// - windows registry; then /// - hxe installation path /// </summary> /// <returns> /// Executable object if found. /// </returns> /// <exception cref="FileNotFoundException"> /// Executable has not been found on the file-system. /// </exception> public static Executable Detect() { var hce = Detection.Infer(); if (System.IO.File.Exists(hce.FullName)) { return((Executable)hce.FullName); } throw new FileNotFoundException("Could not detect executable on the filesystem."); }