How to get Linux OS name using c#.net core

Prabs 1 Reputation point
2021-04-05T09:03:47.843+00:00

How to get Linux OS name using c#.net core?
I used on windows below code, but i need on linux

string windowsName = RegistryHelper.ReadRegistry(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName").ToString();

Developer technologies | .NET | .NET Runtime
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Timon Yang-MSFT 9,606 Reputation points
    2021-04-06T05:23:41.243+00:00

    You can try to use Process and pass the appropriate Linux commands like the method in the link below.

    Finding available space for a directory in C# on Linux

    I don't have a Linux environment so I haven't tested it. You can try it.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.