Where should I put my configuration file?

A

Author

This may sound like a silly question.

I rarely do console or windows form applications.

In a console application, I have an XML configuration file. I place
it under my application root. In my code, I also say

string configFilePath = "./configuration.xml";

When I debug the application with VS 2005, I get an error which says
the configuration file cannot be found. The reason is because when
debug starts, the executable is placed under ApplicationRoot/bin/
Debug/. And as long as I don't copy this configuration.xml file to
ApplicationRoot/bin/Debug/, the complaint is justified. But to keep
copying the file is annoying every time a change is made.

And this bin/Debug folder isn't available in the VS 2005 Solution
Explorer pane. In other words, I cannot directly put the
configuration.xml file under bin/Debug/.

How do you gurus go about this? There must a more professional/easier
way to handle this. Any hint is highly appreciated.
 
D

Duggi

This may sound like a silly question.

I rarely do console or windows form applications.

In a console application, I have an XML configuration file. I place
it under my application root. In my code, I also say

string configFilePath = "./configuration.xml";

When I debug the application with VS 2005, I get an error which says
the configuration file cannot be found. The reason is because when
debug starts, the executable is placed under ApplicationRoot/bin/
Debug/. And as long as I don't copy this configuration.xml file to
ApplicationRoot/bin/Debug/, the complaint is justified. But to keep
copying the file is annoying every time a change is made.

And this bin/Debug folder isn't available in the VS 2005 Solution
Explorer pane. In other words, I cannot directly put the
configuration.xml file under bin/Debug/.

How do you gurus go about this? There must a more professional/easier
way to handle this. Any hint is highly appreciated.

Add new item "Application configuration file" to the project and place
your configuration in the file.

Rest of the things Visual studio takes care.

-Cnu
 
F

Family Tree Mike

You have to change the property on the file in VS "Copy to Output Directory".
The default for xml files will not copy to the output folder.
 
A

Author

Add new item "Application configuration file" to the project and place
your configuration in the file.

Rest of the things Visual studio takes care.

-Cnu

Thank you very much. That must the solution for configuration files.
How about image files which I place under a folder called "images"?
Should I simply put the folder under the application root, but in my
code I say:

string pathToImagesFolder = "../../images";

?
 
D

Duggi

Thank you very much.  That must the solution for configuration files.
How about image files which I place under a folder called "images"?
Should I simply put the folder under the application root, but in my
code I say:

string pathToImagesFolder = "../../images";

?- Hide quoted text -

- Show quoted text -


If they are small size images like, gif or icons... they can directly
go into resources, If you believe resource file will get more in size,
try using them as external resources.

under properties you can see resources.resx in the solution
explorer.... I hope you can explore from there

-Cnu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top