Skip to content

Commit

Permalink
将程序的启动路径设置为正确的路径
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jun 23, 2024
1 parent 07a8fcc commit b7e871b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Core/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
//初始化文件和目录
Expand Down
3 changes: 3 additions & 0 deletions Desktop/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.AspNetCore.Http.Features;
using System.IO;



Expand All @@ -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<ISnackbarService, SnackbarService>();
Expand Down
1 change: 1 addition & 0 deletions Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
1 change: 1 addition & 0 deletions Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b7e871b

Please sign in to comment.