Пример #1
0
        /// <summary>
        /// Gets the games folder path.
        /// </summary>
        public static IEnumerable <string> GetGamesFolderPaths()
        {
            string SteamPath   = SteamHelper.GetSteamAppsPath();
            string LibraryPath = SteamHelper.GetLibraryPath();
            string LibraryFile = File.ReadAllText(LibraryPath);

            if (string.IsNullOrEmpty(LibraryFile) == false)
            {
                VProperty Library = VdfConvert.Deserialize(LibraryFile);
                JProperty Json    = Library.ToJson();

                if (Json.Value["1"] != null)
                {
                    string GamesPath = Json.Value["1"].ToObject <string>();

                    if (string.IsNullOrEmpty(GamesPath) == false)
                    {
                        if (string.IsNullOrEmpty(GamesPath) == false)
                        {
                            string CommonPath = Path.Combine(GamesPath, "steamapps\\common\\");

                            if (string.IsNullOrEmpty(CommonPath) == false)
                            {
                                yield return(CommonPath);
                            }
                            else
                            {
                                Log.Warning(typeof(SteamHelper), "CommonPath is empty.");
                            }
                        }
                        else
                        {
                            Log.Warning(typeof(SteamHelper), "GamesPath is empty.");
                        }
                    }
                    else
                    {
                        Log.Warning(typeof(SteamHelper), "GamesPath property is empty.");
                    }
                }
                else
                {
                    Log.Warning(typeof(SteamHelper), "LibraryFolders property is empty.");
                }
            }
            else
            {
                Log.Error(typeof(SteamHelper), "Empty ?");
            }

            yield return(Path.Combine(SteamPath, "common"));
        }
Пример #2
0
        /// <summary>
        /// Detects the steam games library path.
        /// </summary>
        public static string GetLibraryPath()
        {
            var AppsPath = SteamHelper.GetSteamAppsPath();

            if (string.IsNullOrEmpty(AppsPath) == false)
            {
                var AppsFiles = Directory.GetFiles(AppsPath);

                if (AppsFiles.Contains("libraryfolders.vdf", new PathEndingComparer()))
                {
                    return(Path.Combine(AppsPath, "libraryfolders.vdf"));
                }
                else
                {
                    Log.Warning(typeof(SteamHelper), "LibraryFolders.vdf don't exist.");
                }
            }
            else
            {
                Log.Warning(typeof(SteamHelper), "SteamApps is empty.");
            }

            return(string.Empty);
        }