public static void determineTargetPlatform() { if (Environment.OSVersion.Platform.Equals(PlatformID.Unix)) { string unameResult = ""; ProcessStartInfo startInfo = new ProcessStartInfo("uname", "-s"); startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; startInfo.WindowStyle = ProcessWindowStyle.Hidden; System.Diagnostics.Process proc = Process.Start(startInfo); try { System.IO.StreamReader output = proc.StandardOutput; proc.WaitForExit(); if (!proc.HasExited) { throw new ApplicationException("Timed out in effort to determine Operating System Information"); } unameResult = output.ReadToEnd(); } catch { currentPlatform = LikewiseTargetPlatform.UnixOrLinux; } if (unameResult.Contains("Darwin")) { currentPlatform = LikewiseTargetPlatform.Darwin; } else { currentPlatform = LikewiseTargetPlatform.UnixOrLinux; } } else { currentPlatform = LikewiseTargetPlatform.Windows; } }
public static void determineTargetPlatform() { if (Environment.OSVersion.Platform.Equals(PlatformID.Unix)) { string unameResult = ""; ProcessStartInfo startInfo = new ProcessStartInfo("uname", "-s"); startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; startInfo.WindowStyle = ProcessWindowStyle.Hidden; System.Diagnostics.Process proc = Process.Start(startInfo); try { System.IO.StreamReader output = proc.StandardOutput; proc.WaitForExit(); if (!proc.HasExited) { throw new ApplicationException("Timed out in effort to determine Operating System Information"); } unameResult = output.ReadToEnd(); } catch { currentPlatform = LikewiseTargetPlatform.UnixOrLinux; } if (unameResult.Contains("Darwin")) { currentPlatform = LikewiseTargetPlatform.Darwin; } else { currentPlatform = LikewiseTargetPlatform.UnixOrLinux; } } else { currentPlatform = LikewiseTargetPlatform.Windows; } }