/// <summary> /// Gets the game path. /// </summary> /// <param name="GameName">Name of the game.</param> public static string GetGamePath(string GameName) { if (SteamHelper.IsGameInstalled(GameName)) { var GameFolders = SteamHelper.GetGamesFolderPaths().ToList(); if (GameFolders.Any()) { foreach (var GameFolder in GameFolders) { var Games = Directory.GetDirectories(GameFolder); if (Games.Contains(GameName, new PathEndingComparer())) { return(Path.Combine(GameFolder, GameName)); } } } else { Log.Warning(typeof(SteamHelper), "GameFolders is empty."); } } else { Log.Warning(typeof(SteamHelper), "Game is not installed."); } return(string.Empty); }
/// <summary> /// Gets the installed games. /// </summary> public static IEnumerable <string> GetInstalledGames() { var GameFolders = SteamHelper.GetGamesFolderPaths().ToList(); if (GameFolders.Any()) { foreach (var GameFolder in GameFolders) { var Games = Directory.GetDirectories(GameFolder); foreach (var Game in Games) { int LastSlash = Game.LastIndexOf('\\') + 1; if (LastSlash != 0) { yield return(Game.Substring(LastSlash, Game.Length - LastSlash)); } } } } else { Log.Warning(typeof(SteamHelper), "GameFolders is empty."); } }