2019/03/14

.Net Core Determine OS



using System;
using System.Runtime.InteropServices;

namespace ShowOSConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                Console.WriteLine(RuntimeInformation.OSDescription);
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                Console.WriteLine(RuntimeInformation.OSDescription);
            else
                Console.WriteLine(RuntimeInformation.OSDescription);

            Console.WriteLine("輸入任何鍵結束");
            Console.ReadKey();
        }
    }
}

沒有留言:

張貼留言