allencoded allencoded - 1 month ago 33
C# Question

System.Environment.OSVersion .NET Core 5.0 Framework replacement?

System.Environment.OSVersion
doesn't seem to be a part of .net core 5.0 (dnxcore50).

I am trying to determine which OS a user is on so when they save a file to the filesystem I know rather to use '/' or '\'

What should I use instead?

lkg lkg
Answer

Don't do the detection yourself. Use System.IO.Path.DirectorySeparatorChar. Also, if you always use Path to manipulate paths then you should get formatting that you need. This also works with URLs.