Exemple #1
0
        public string GetGameVersion()
        {
            string version = string.Empty;

            if (string.IsNullOrEmpty(ApplicationSettings.Arma3Path))
            {
                Logger.LogDebug("SettingsService", "Unable to detect game version, path is not set");
                return(version);
            }

            var gamePath = Path.Combine(ApplicationSettings.Arma3Path, ApplicationConfig.GameExecutable32);

            if (!_fileAccessor.FileExists(gamePath))
            {
                Logger.LogException("SettingsService", "Unable to detect game version, game executable not found");
                return(version);
            }

            try
            {
                FileVersionInfo info = _fileAccessor.GetFileVersionInfo(Path.Combine(ApplicationSettings.Arma3Path, ApplicationConfig.GameExecutable32));
                version = info.FileVersion + "." + info.FileBuildPart + info.FilePrivatePart;

                Logger.LogDebug("SettingsService", $"Local game version detected to be: {version}");
            }
            catch (Exception e)
            {
                version = string.Empty;
                Logger.LogException("SettingsService", "Error detecting game version", e);
            }

            return(version);
        }