Files
better-genshin-impact/BetterGenshinImpact/Core/Config/Global.cs
huiyadanli c2ac8dff77 0.16.1
2023-11-26 00:08:17 +08:00

52 lines
1.3 KiB
C#

using System;
using System.IO;
namespace BetterGenshinImpact.Core.Config;
public class Global
{
public static string Version = "0.16.1";
public static string StartUpPath { get; private set; } = AppContext.BaseDirectory;
public static string AppPath { get; private set; } = Absolute("BetterGI.exe");
public static string Absolute(string relativePath)
{
return Path.Combine(StartUpPath, relativePath);
}
public static string? ReadAllTextIfExist(string relativePath)
{
var path = Absolute(relativePath);
if (File.Exists(path))
{
return File.ReadAllText(path);
}
return null;
}
public static bool IsNewVersion(string currentVersion)
{
return IsNewVersion(Version, currentVersion);
}
public static bool IsNewVersion(string oldVersion, string currentVersion)
{
var currentVersionArr = oldVersion.Split('.');
var newVersionArr = currentVersion.Split('.');
if (currentVersionArr.Length != newVersionArr.Length)
{
return false;
}
for (int i = 0; i < currentVersionArr.Length; i++)
{
if (int.Parse(currentVersionArr[i]) < int.Parse(newVersionArr[i]))
{
return true;
}
}
return false;
}
}