473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Where should I put my configuration file?

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.

Jun 27 '08 #1
5 2065
MC
Windows provides a per-user Application Data space, with a simple way for programs to locate it, which someone else will hopefully tell us the details of.

In a properly configured multi-user Windows system, programs do not normally have permission, at run time, to write in the directories where they are installed. This is important for security.


Jun 27 '08 #2
On Jun 19, 7:03 pm, Author <gnewsgr...@gmail.comwrote:
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

Jun 27 '08 #3
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.

"Duggi" wrote:
On Jun 19, 7:03 pm, Author <gnewsgr...@gmail.comwrote:
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

Jun 27 '08 #4
On Jun 19, 11:14*am, Duggi <DuggiSrinivasa...@gmail.comwrote:
On Jun 19, 7:03 pm, Author <gnewsgr...@gmail.comwrote:
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
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";

?
Jun 27 '08 #5
On Jun 19, 9:09*pm, Author <gnewsgr...@gmail.comwrote:
On Jun 19, 11:14*am, Duggi <DuggiSrinivasa...@gmail.comwrote:


On Jun 19, 7:03 pm, Author <gnewsgr...@gmail.comwrote:
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

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
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexander Kienzle | last post by:
I'm new to Java programming. I'm developing a Servlet for tomcat which needs an external configuration file. With external I mean a file (in XML format) which is customizable and not contained in...
2
by: kathy | last post by:
What Application Configuration File is? And when/where/how to use it? Any documents on that? MSDN has somrthings scatter everywhere - hard to follow. thanks,
6
by: Serge calderara | last post by:
Dear all, Does any one have a ready class that is able to access a configuration file and make different type of querry, read, write operation? Why re invanting the real if something already...
4
by: Steve Enzer | last post by:
I need to use a configuration file to set the connection string for the ado data connector in my project, but I'm having trouble reading the config file. My config file contains the following: ...
7
by: serge calderara | last post by:
Dear all, I am building an ASP 1.1 application based on a n-Tier architecture. I have my datalayer class that need to read the connection string of my sql server database from a configuration...
7
by: Ben R. | last post by:
Hi, I'm working on an ASP.NET 2.0 site and my hosting provider has the root in a different place than I have it locally which is not a problem for most things, except for the access oledb...
0
by: Amigo | last post by:
Hello all! I have just started learning C# a couple of weeks ago. I went through a few tutorials and now I am thinking of starting a real application to learn it better. The application is a...
1
by: Erwin Moller | last post by:
Hi, Why does phpinfo() show two locations for php.ini? This is what it says: Configuration File (php.ini) Path: C:\Windows Loaded Configuration File : C:\inetpub\php5\php.ini The...
1
by: ashi1290 | last post by:
I am getting this error..... Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.