How do I determine what platform my C# code is running on? for example whether it is running on Linux or windows so that I can execute different code at runtime.
I h
One more option is to use Process to call a shell script to get the uname, as follows:
Process p = new Process {
StartInfo = {
UseShellExecute = false,
RedirectStandardOutput = true,
FileName = "uname",
Arguments = "-s"
}
};
p.Start();
string uname = p.StandardOutput.ReadToEnd().Trim();
if (uname == "Darwin") {
// OS X
} else {
// ...
}