Thanks
No, the app.config must be in the same directory as the project and the Settings.Settings file is generated by the IDE and needs to match the generated code in the project for it.
If the settings you are referring to are in app.config, there is an extra attribute you can add to that file to reference a secondary configuration file that is in another [relative] location. This attribute causes information from the secondary file to be merged with the current file. I did this once to allow me to have a single settings (app.config) file in a centralized location (a network share) so that if any of the settings changed I didn't have to go update x-number of settings files located on x-number of computers. Your application code doesn't need to change with this approach, as the merging is handled automatically.
You can look this up in the help file to see if it is what you want/need. The basic syntax is as follows:
Main application app.config:
< xml version="1.0" encoding="utf-8" >
<configuration>
<appSettings file="Secondary.Global.config">
<add key="MyKey" value="MyValue"/>
</appSettings>
</configuration>
Secondary configuration file:
< xml version="1.0" encoding="utf-8" >
<appSettings>
<add key="MyOtherKey" value="MyOtherValue"/>
</appSettings>
...ends up creating a file configuration file (at runtime) that looks like this to your application:
< xml version="1.0" encoding="utf-8" >
<configuration>
<appSettings>
<add key="MyKey" value="MyValue"/>
<add key="MyOtherKey" value="MyOtherValue"/>
</appSettings>
</configuration>
You will need to create xml configuration file in order to have one common setting file. But i think that this can be avoided as a need if you change your application's design. What i mean by that is that if you need some common thing, then that could be placed in separate library that will be used by both applications. Again you will have xml configuration file. I will describe it in a scenario.
Imagine you have data access layer which needs connection settings. If you place this data layer that needs that connection properties in applications, which both use same connection, than solution is to move all source for data layer in separate assembly and both applications will use same assembly for accessing database, using same connection properties. And it's common way of storring assembly configurable variables in xml config file.
rutlean wrote:
What I am actually doing is saving a meter address and a com port. One application is the configurator, it sets the meter address and the com port number. The second application is a calibrator tool that communicates with a motion controller through the saved com port number and communicates with HP Voltage meter through the HPIB address that was saved as well.
It sounds like the xml is the way to go. Will both applications be able to read and write to the file
Thanks for the info.
Andy
Yes, but see Using Settings in C# for more info.
rutlean wrote:
I am new to creating a XML application file. What is the best way to create one Is it generated like the settings files inside the project properties page <br><br>Thanks<br>
I assume you me app.config by "XML Application file". The easiest way is to add one to your project. Right click your project in Solution Explorer and select "Add\New Item", then double-click the "Application Configuration File" Icon.