diff --git a/BurnOutSharp/Tools/Utilities.cs b/BurnOutSharp/Tools/Utilities.cs index a59eec63..b25232c0 100644 --- a/BurnOutSharp/Tools/Utilities.cs +++ b/BurnOutSharp/Tools/Utilities.cs @@ -1,13 +1,11 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Security.Cryptography; using BurnOutSharp.Interfaces; using BurnOutSharp.Wrappers; -using psxt001z; namespace BurnOutSharp.Tools { @@ -690,6 +688,27 @@ namespace BurnOutSharp.Tools #region Processed Executable Information + /// + /// Get the internal version as reported by the filesystem + /// + /// File to check for version + /// Version string, null on error + public static string GetInternalVersion(string file) + { + try + { + using (Stream fileStream = File.OpenRead(file)) + { + var pex = PortableExecutable.Create(fileStream); + return GetInternalVersion(pex); + } + } + catch + { + return string.Empty; + } + } + /// /// Get the internal version as reported by the resources /// @@ -712,46 +731,10 @@ namespace BurnOutSharp.Tools return null; } - /// - /// Get the internal version as reported by the filesystem - /// - /// File to check for version - /// Version string, null on error - public static string GetInternalVersion(string file) - { - var fvinfo = GetFileVersionInfo(file); - if (fvinfo?.FileVersion == null) - return string.Empty; - if (fvinfo.FileVersion != "") - return fvinfo.FileVersion.Replace(", ", "."); - else - return fvinfo.ProductVersion.Replace(", ", "."); - } - #endregion #region Executable Information - /// - /// Get the file version info object related to a path, if possible - /// - /// File to get information for - /// FileVersionInfo object on success, null on error - private static FileVersionInfo GetFileVersionInfo(string file) - { - if (file == null || !File.Exists(file)) - return null; - - try - { - return FileVersionInfo.GetVersionInfo(file); - } - catch - { - return null; - } - } - /// /// Get the SHA1 hash of a file, if possible ///