Beispiel #1
0
        private string[] GetInstallLocationsFromSteamConfig(string steamPath)
        {
            var configPath = Path.Combine(steamPath, "config", "config.vdf");

            if (!File.Exists(configPath))
            {
                return(new string[0]);
            }
            var configContent = File.ReadAllText(configPath);

            var configJson = VdfFileReader.ToJson(configContent);

            var deserialized = JsonConvert.DeserializeObject <SteamConfig>(configJson);

            var steamConfigInstallKeys = deserialized.Software.Valve.Steam.Keys.Where(x => x.StartsWith("BaseInstallFolder_"));

            List <string> results = new List <string>();

            foreach (var k in steamConfigInstallKeys)
            {
                var val = deserialized.Software.Valve.Steam[k] as string;
                if (string.IsNullOrEmpty(val))
                {
                    continue;
                }
                var fullGDPath = Path.Combine(val, "SteamApps", "common", "Grim Dawn").Replace('/', '\\');
                results.Add(fullGDPath);
            }

            return(results.ToArray());
        }
Beispiel #2
0
        public void TestConvertVdfToJson()
        {
            var fileContent = File.ReadAllText("Resources\\config.vdf");
            var jsonContent = VdfFileReader.ToJson(fileContent);

            var jsonObject = JsonConvert.DeserializeObject(jsonContent);

            Assert.IsNotNull(jsonObject);
        }