This commit is contained in:
2509_92447106 committed 2026-11-08 17:29:32 +08:00
commit 1ee49b8966
1125 files changed
+32542

No files matched your search

@@ -0,0 +1,49 @@
using System;
using System.Diagnostics;
using System.IO;
namespace EarthModelStudio.Services;
public static class Shell
{
public static void OpenFolder(string path)
{
if (string.IsNullOrWhiteSpace(path)) return;
try
{
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
StartWith(path);
}
catch (Exception ex)
{
Console.Error.WriteLine($"打开目录失败: {ex.Message}");
}
}
/// <summary>用系统默认浏览器打开一个 URL。</summary>
public static void OpenUrl(string url)
{
if (string.IsNullOrWhiteSpace(url)) return;
try
{
StartWith(url);
}
catch (Exception ex)
{
Console.Error.WriteLine($"打开链接失败: {ex.Message}");
}
}
private static void StartWith(string argument)
{
var info = new ProcessStartInfo
{
FileName = OperatingSystem.IsWindows() ? "explorer.exe"
: OperatingSystem.IsMacOS() ? "open"
: "xdg-open",
UseShellExecute = false
};
info.ArgumentList.Add(argument);
Process.Start(info);
}
}