sharp-chat/SharpChat/SharpInfo.cs

36 lines
1.1 KiB
C#
Raw Normal View History

using System.IO;
using System.Reflection;
namespace SharpChat {
public static class SharpInfo {
private const string NAME = @"SharpChat";
private const string UNKNOWN = @"XXXXXXX";
public static string VersionString { get; }
public static string VersionStringShort { get; }
public static bool IsDebugBuild { get; }
public static string ProgramName { get; }
static SharpInfo() {
#if DEBUG
IsDebugBuild = true;
#endif
try {
2024-05-10 19:18:55 +00:00
using Stream? s = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"SharpChat.version.txt");
if(s != null) {
using StreamReader sr = new(s);
VersionString = sr.ReadLine()?.Trim() ?? string.Empty;
} else
VersionString = string.Empty;
VersionStringShort = VersionString.Length > 10 ? VersionString[..10] : VersionString;
} catch {
VersionStringShort = VersionString = UNKNOWN;
}
2024-05-10 19:18:55 +00:00
ProgramName = string.Format(@"{0}/{1}", NAME, VersionStringShort);
}
}
}