C# 判断操作系统是 Windows 还是 Linux


示例代码如下:

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
    // Windows 相关逻辑
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
    // Linux 相关逻辑
}

相关