question

Prabs-7622 avatar image
0 Votes"
Prabs-7622 asked TimonYang-MSFT commented

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

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();

dotnet-csharpdotnet-runtime
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TimonYang-MSFT avatar image
0 Votes"
TimonYang-MSFT answered TimonYang-MSFT commented

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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, the code has to work on both windows and linux

0 Votes 0 ·

@Prabs-7622
I have some doubts whether this is possible.
Detecting the current OS type and then executing different codes may be an option. For the caller, it makes no difference. They always only need to call one method.
Refer to my reply in another thread.

0 Votes 0 ·