Files
downkyicore/DownKyi/Utils/PlatformHelper.cs
2023-12-14 22:04:15 +08:00

41 lines
900 B
C#

using System;
using System.Diagnostics;
namespace DownKyi.Utils;
public static class PlatformHelper
{
/// <summary>
/// 打开文件夹
/// </summary>
/// <param name="folder">路径</param>
public static void OpenFolder(string folder)
{
if (OperatingSystem.IsWindows())
{
Process.Start("explorer.exe", $"/select,{folder}");
}
if (OperatingSystem.IsMacOS())
{
Process.Start("open", $"\"{folder}\"");
}
}
/// <summary>
/// 打开各种 (文件、url)
/// </summary>
/// <param name="filename">文件名</param>
public static void Open(string filename)
{
if (OperatingSystem.IsWindows())
{
Process.Start(filename);
}
if (OperatingSystem.IsMacOS())
{
Process.Start("open", $"\"{filename}\"");
}
}
}