【问题标题】:What is the best way to test at runtime whether .NET Core application is running on Windows or Linux? [duplicate]在运行时测试 .NET Core 应用程序是在 Windows 还是 Linux 上运行的最佳方法是什么? [复制]
【发布时间】:2018-04-15 21:37:12
【问题描述】:

使用 .NET Core 2.0 在运行时测试应用程序是在 Windows 还是 Linux 上运行的最佳方法是什么?

例如,假设我在 Windows 和 Linux 机器上部署了一个 .NET Core 应用程序,它需要访问存储在文件中的本地资源。显然,这些文件的路径(和路径格式)会有所不同,那么最好的方法是什么?

【问题讨论】:

标签: c# linux windows .net-core .net-standard


【解决方案1】:

您可以查看System.Environment.OSVersion.Platform属性。

【讨论】:

    猜你喜欢
    • 2012-08-24
    • 1970-01-01
    • 1970-01-01
    • 2020-02-05
    • 1970-01-01
    • 2011-01-01
    • 2011-12-14
    • 2010-09-13
    • 1970-01-01
    相关资源
    最近更新 更多