diff --git a/Netch/Netch.cs b/Netch/Netch.cs index 93cf2b97..a034b957 100644 --- a/Netch/Netch.cs +++ b/Netch/Netch.cs @@ -13,18 +13,14 @@ namespace Netch public static class Netch { /// - /// 应用程序的主入口点 + /// 应用程序的主入口点 /// [STAThread] public static void Main(string[] args) { if (args.Contains("-console")) - { if (!NativeMethods.AttachConsole(-1)) - { NativeMethods.AllocConsole(); - } - } // 创建互斥体防止多次运行 using (var mutex = new Mutex(false, "Global\\Netch")) @@ -36,12 +32,8 @@ namespace Netch // 预创建目录 var directories = new[] {"mode", "data", "i18n", "logging"}; foreach (var item in directories) - { if (!Directory.Exists(item)) - { Directory.CreateDirectory(item); - } - } // 加载配置 Configuration.Load(); @@ -49,6 +41,12 @@ namespace Netch // 加载语言 i18N.Load(Global.Settings.Language); + if (!Directory.Exists("bin") || !Directory.EnumerateFileSystemEntries("bin").Any()) + { + MessageBoxX.Show(i18N.Translate("Please extract all files then run the program!")); + Environment.Exit(2); + } + // 检查是否已经运行 if (!mutex.WaitOne(0, false)) { @@ -65,21 +63,14 @@ namespace Netch var directory = new DirectoryInfo("logging"); foreach (var file in directory.GetFiles()) - { file.Delete(); - } foreach (var dir in directory.GetDirectories()) - { dir.Delete(true); - } } Logging.Info($"版本: {UpdateChecker.Owner}/{UpdateChecker.Repo}@{UpdateChecker.Version}"); - Task.Run(() => - { - Logging.Info($"主程序 SHA256: {Utils.Utils.SHA256CheckSum(Application.ExecutablePath)}"); - }); + Task.Run(() => { Logging.Info($"主程序 SHA256: {Utils.Utils.SHA256CheckSum(Application.ExecutablePath)}"); }); Task.Run(() => { Logging.Info("启动单实例"); diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN index e9bcaa16..a9332306 100644 --- a/Netch/Resources/zh-CN +++ b/Netch/Resources/zh-CN @@ -6,6 +6,7 @@ "If this is your first time using this software,\n please check https://netch.org to install supports first,\n or the program may report errors.": "如果你是第一次使用本软件,\n请务必前往 https://netch.org 安装程序所需依赖,\n否则程序将无法正常运行!", "Netch is already running": "Netch 已经在运行中", "Missing File or runtime components": "缺少文件或运行库", + "Please extract all files then run the program!": "请先解压所有文件再执行程序!", "Start": "启动", "Stop": "停止",