Skip to content

Checking the running os in c#

jayabhargava r

Asked Nov 24, 2012, 3:07 AM EST2 answers
Share
LinkedInX
I have a project developed in visual studio. and it is hosted on remote windows server for running. I have written some code which does specific things based on the os  (windows , Mac ). but when I access the site via URL  in Mac...it always executes the  windows specific code. what might be the reason....?

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0
    Is the code Mac compliant? Some .NET code may not run on Mac.
    0
  • 0
     if( Environment.OSVersion.VersionString.Contains("Windows")){
                 console.Writeline("windows environment");
               }
    else
            console.Writeline("Mac/Linux environment");
            
    console.Writeline(Environment.OSVersion.VersionString);


    ...according to these lines  of code in mac os i am not getting else part result.. and 
    Environment.OSVersion.VersionString is displaying the value as : Microsoft Windows NT 6.1.7601 Service Pack 1..

    so what might be the problem?






    0