开发者

C# System.PlatformID.Unix vs. Linux

开发者 https://www.devze.com 2023-01-10 13:04 出处:网络
Question: I need to make some system calls in my C# applications. Unfortunately, this behaves differently on Linux than on UNIX.

Question:

I need to make some system calls in my C# applications. Unfortunately, this behaves differently on Linux than on UNIX.

Now I used to switch the Operating system at runtime like this

If Environment.OSVersion.Platform = Sy开发者_StackOverflow中文版stem.PlatformID.Unix Then
    ' Linux/Unix '
ElseIf Environment.OSVersion.Platform = System.PlatformID.MacOSX Then
    ' Apple '
Else
    ' Windows '
End If

The problem now is I need to differentiate between UNIX and Linux, because they are different.

Is there a way I can figure out whether the OS is Linux or Unix? Preferably not by invoking uname -a

I wouldn't like to abandon Unix and make it Linux only, just because Microsoft did not add a PlatformID.Linux...


You will need to use "uname -a" to distinguish Linux from Unix, as well as OSX. For historical reasons, Mono reports OSX as Unix, not MacOSX.

Some code that uses uname is available here: http://github.com/jpobst/Pinta/blob/master/Pinta/Platform.cs

0

精彩评论

暂无评论...
验证码 换一张
取 消