Question

I am trying to find a way to determine which operating system a user has (i.e. win7, or xp) from the App.Config file in my C# windows console application project. I currently have it working programatically in the .cs file but I cannot seem to locate any information on whether it is possible or not. Idealy I would have a setting in the config file that will specify which network location to use for grabbing files to copy to the local machine. This will make the code independent of the operating system version.

Was it helpful?

Solution

If you just want to map windows versions to paths you can make a custom config section that would look like that: (I'm basing the version numbers on this answer)

<pathsByVersionSection>
    <pathsByVersion>
        <version major="5" minor="1" path="xp-path" />
        <version major="6" minor="1" path="win7-path" />
    </pathsByVersion>
</pathsByVersionSection>

and if windows 8 is added you will be able to add an element:

<version major="6" minor="2" path="win8-path" />

An example of making a custom config section with a collection can be found here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top