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

示例代码如下:

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

  

原文地址:https://www.cnblogs.com/dhqy/p/15787463.html