sharp-chat/SharpChat/SharpInfo.cs

37 lines
1.1 KiB
C#

using System.IO;
using System.Reflection;
using System.Text;
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 {
using Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"SharpChat.version.txt");
using StreamReader sr = new(s);
VersionString = sr.ReadLine().Trim();
VersionStringShort = VersionString.Length > 10 ? VersionString[..10] : VersionString;
} catch {
VersionStringShort = VersionString = UNKNOWN;
}
StringBuilder sb = new();
sb.Append(NAME);
sb.Append('/');
sb.Append(VersionStringShort);
ProgramName = sb.ToString();
}
}
}