From b7e871b4826cf353ccd151c7aee13a957137e4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3?= Date: Mon, 24 Jun 2024 01:12:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E7=A8=8B=E5=BA=8F=E7=9A=84=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E8=B7=AF=E5=BE=84=E8=AE=BE=E7=BD=AE=E4=B8=BA=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Init.cs | 2 +- Desktop/App.xaml.cs | 3 +++ Server/Program.cs | 1 + Server/Startup.cs | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/Init.cs b/Core/Init.cs index 4ca6c6085..69e436302 100644 --- a/Core/Init.cs +++ b/Core/Init.cs @@ -47,7 +47,7 @@ public static void Start(string[] args) //启动参数初始化 StartParameterInitialization(args); - + Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;//将当前路径从 引用路径 修改至 程序所在目录 AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true); //初始化文件和目录 diff --git a/Desktop/App.xaml.cs b/Desktop/App.xaml.cs index 481a9b569..a936b0a96 100644 --- a/Desktop/App.xaml.cs +++ b/Desktop/App.xaml.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.DependencyInjection; using System; using Microsoft.AspNetCore.Http.Features; +using System.IO; @@ -29,6 +30,8 @@ protected override void OnStartup(StartupEventArgs e) { try { + Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); + Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;//将当前路径从 引用路径 修改至 程序所在目录 base.OnStartup(e); var services = new ServiceCollection(); services.AddSingleton(); diff --git a/Server/Program.cs b/Server/Program.cs index 49ec4aa2d..1f44a71c2 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -27,6 +27,7 @@ public class Program public static async Task Main(string[] args) { + Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); try { if (!Array.Exists(args, element => element.Contains("--StartMode"))) diff --git a/Server/Startup.cs b/Server/Startup.cs index 0bc584e88..10c8113d7 100644 --- a/Server/Startup.cs +++ b/Server/Startup.cs @@ -41,6 +41,7 @@ public void ConfigureServices(IServiceCollection services) // 这个方法用于配置HTTP请求管道 public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); ServicePointManager.DnsRefreshTimeout = 0; ServicePointManager.DefaultConnectionLimit = 4096 * 16; ServicePointManager.Expect100Continue = false;