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;