public static string RecordLatestInstalledVersion(string gameTitle, string gameVersion, bool overwrite) { var versionPath = Installer.GetBasePath(gameTitle); versionPath = Path.Combine(versionPath, "Versions"); versionPath = Path.Combine(versionPath, "Latest.txt"); if (overwrite || !File.Exists(versionPath)) { File.WriteAllText(versionPath, gameVersion); } return(null); }
public static void Save() { string logPath; try { // Build the path logPath = Installer.GetBasePath(); logPath = Path.Combine(logPath, "Logs"); logPath = Path.Combine(logPath, DateTime.Now.ToString("s").Replace(":", "-") + ".txt"); // Prepare the directory var logDirectory = Path.GetDirectoryName(logPath); if (!Directory.Exists(logDirectory)) { // Create the log file directory Directory.CreateDirectory(logDirectory); } else { // Delete old log files from the directory var directoryInfo = new DirectoryInfo(logDirectory); var oldFiles = directoryInfo.EnumerateFiles() .Where(file => file.Extension == ".txt") .OrderByDescending(file => file.CreationTime) .Skip(4); foreach (var file in oldFiles.ToList()) { file.Delete(); } } } catch (Exception) { logPath = "Log.txt"; } // Write the log try { Log("Writing log file to {0}", logPath); lock ( s_log ) { File.WriteAllText(logPath, s_log.ToString()); } } catch (Exception) { Log("Failed to write log file to {0}", logPath); } }
public static string GetLatestInstalledVersion(string gameTitle) { var versionPath = Installer.GetBasePath(gameTitle); versionPath = Path.Combine(versionPath, "Versions"); versionPath = Path.Combine(versionPath, "Latest.txt"); if (File.Exists(versionPath)) { string gameVersion = File.ReadAllText(versionPath).Trim(); if (IsGameInstalled(gameTitle, gameVersion)) { return(gameVersion); } } return(null); }