473,473 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

can't read config file

i've followed the instructions i found here about how to add a config file
to my applicaiton:
http://www.c-sharpcorner.com/Code/20...onfigFiles.asp

the instructions state that i create a config file named after the
executable, so, as my exe is timeTracker.exe, i've created a file called
timeTracker.exe.config and placed it in the bin/debug folder. i then added a
reference to the file in VS by selecting "File/Add existing item". VS
replicates the config file under the project's root folder (even though the
config file is already in the bin/debug folder). when i then run the app and
try to read a value from the file, i get nothing. when i look in the
bin/debug folder, the config file is gone (though it still exists in the
project root folder). any ideas what's going wrong?
Nov 17 '05 #1
5 2323
The reason VS does not keep the file in the same place is that the solution
explorer treats all files under the top level for a project as being
contained in the project folder (or subfolders if defined).

Try selecting the "Show All Files" option (under the solution explorer
titlebar) and then drilling down into Bin/Debug. Once there you can drag and
drop the .config file into this area, and it should remain there following a
build.

If this doesnt work, you could always define a post-build script to copy
from the project level down into the Bin/Debug directory.
---
Chris Ballard
MCSD.NET
"Dica" wrote:
i've followed the instructions i found here about how to add a config file
to my applicaiton:
http://www.c-sharpcorner.com/Code/20...onfigFiles.asp

the instructions state that i create a config file named after the
executable, so, as my exe is timeTracker.exe, i've created a file called
timeTracker.exe.config and placed it in the bin/debug folder. i then added a
reference to the file in VS by selecting "File/Add existing item". VS
replicates the config file under the project's root folder (even though the
config file is already in the bin/debug folder). when i then run the app and
try to read a value from the file, i get nothing. when i look in the
bin/debug folder, the config file is gone (though it still exists in the
project root folder). any ideas what's going wrong?

Nov 17 '05 #2

"Chris Ballard" <wo*********@typeYAHOOhere.com> wrote in message
news:B4**********************************@microsof t.com...
The reason VS does not keep the file in the same place is that the solution explorer treats all files under the top level for a project as being
contained in the project folder (or subfolders if defined).

Try selecting the "Show All Files" option (under the solution explorer
titlebar)
i don't see this option anywhere. i'm using VS 2003. could it be somewhere
else?
and then drilling down into Bin/Debug. Once there you can drag and drop the .config file into this area, and it should remain there following a build.

If this doesnt work, you could always define a post-build script to copy
from the project level down into the Bin/Debug directory.
---
Chris Ballard
MCSD.NET
"Dica" wrote:
i've followed the instructions i found here about how to add a config file to my applicaiton:
http://www.c-sharpcorner.com/Code/20...onfigFiles.asp

the instructions state that i create a config file named after the
executable, so, as my exe is timeTracker.exe, i've created a file called
timeTracker.exe.config and placed it in the bin/debug folder. i then added a reference to the file in VS by selecting "File/Add existing item". VS
replicates the config file under the project's root folder (even though the config file is already in the bin/debug folder). when i then run the app and try to read a value from the file, i get nothing. when i look in the
bin/debug folder, the config file is gone (though it still exists in the
project root folder). any ideas what's going wrong?

Nov 17 '05 #3
"Dica" <ge*****@hotmail.com> wrote in message
news:hP********************@rogers.com...
i've followed the instructions i found here about how to add a config file
to my applicaiton:
http://www.c-sharpcorner.com/Code/20...onfigFiles.asp

the instructions state that i create a config file named after the
executable, so, as my exe is timeTracker.exe, i've created a file called
timeTracker.exe.config and placed it in the bin/debug folder. i then added
a
reference to the file in VS by selecting "File/Add existing item". VS
replicates the config file under the project's root folder (even though
the
config file is already in the bin/debug folder). when i then run the app
and
try to read a value from the file, i get nothing. when i look in the
bin/debug folder, the config file is gone (though it still exists in the
project root folder). any ideas what's going wrong?


Create a file called App.config in the project. To VS this is a magic name
and it copies the file into the target directory with the right name. This
allows you to perform debug and release builds without having to duplicate
the config file

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Nov 17 '05 #4
It is a toolbar button with an icon showing three pages of different colours.
Just above the solution explorer treeview.

However, Richards solution is the correct one to use. Thanks Rich, I always
figured there would be a better way of doing this!
--
Chris Ballard
MCSD.NET
"Dica" wrote:

"Chris Ballard" <wo*********@typeYAHOOhere.com> wrote in message
news:B4**********************************@microsof t.com...
The reason VS does not keep the file in the same place is that the

solution
explorer treats all files under the top level for a project as being
contained in the project folder (or subfolders if defined).

Try selecting the "Show All Files" option (under the solution explorer
titlebar)


i don't see this option anywhere. i'm using VS 2003. could it be somewhere
else?
and then drilling down into Bin/Debug. Once there you can drag and
drop the .config file into this area, and it should remain there following

a
build.

If this doesnt work, you could always define a post-build script to copy
from the project level down into the Bin/Debug directory.
---
Chris Ballard
MCSD.NET
"Dica" wrote:
i've followed the instructions i found here about how to add a config file to my applicaiton:
http://www.c-sharpcorner.com/Code/20...onfigFiles.asp

the instructions state that i create a config file named after the
executable, so, as my exe is timeTracker.exe, i've created a file called
timeTracker.exe.config and placed it in the bin/debug folder. i then added a reference to the file in VS by selecting "File/Add existing item". VS
replicates the config file under the project's root folder (even though the config file is already in the bin/debug folder). when i then run the app and try to read a value from the file, i get nothing. when i look in the
bin/debug folder, the config file is gone (though it still exists in the
project root folder). any ideas what's going wrong?


Nov 17 '05 #5

"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
"Dica" <ge*****@hotmail.com> wrote in message
news:hP********************@rogers.com...
i've followed the instructions i found here about how to add a config file to my applicaiton:
http://www.c-sharpcorner.com/Code/20...onfigFiles.asp

the instructions state that i create a config file named after the
executable, so, as my exe is timeTracker.exe, i've created a file called
timeTracker.exe.config and placed it in the bin/debug folder. i then added a
reference to the file in VS by selecting "File/Add existing item". VS
replicates the config file under the project's root folder (even though
the
config file is already in the bin/debug folder). when i then run the app
and
try to read a value from the file, i get nothing. when i look in the
bin/debug folder, the config file is gone (though it still exists in the
project root folder). any ideas what's going wrong?
Create a file called App.config in the project. To VS this is a magic name
and it copies the file into the target directory with the right name. This
allows you to perform debug and release builds without having to duplicate
the config file


thanks rich. i actually found the option to create this config file from
within VS earlier but then renamed it as described in the tutorial i
mentioned earlier. the articled mentioned nothing about "magic names". my
config file works fine now.

tks again.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Nov 17 '05 #6

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

Similar topics

5
by: Karthikesh Raju | last post by:
Hi All, i am wondering about the best way to read in a configuration file that goes like: ########### source_dir = '/home/karthik/Projects/python' data_dir =...
2
by: MrFile | last post by:
I added an app.config file to my application. (c#.net component dll) <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="username" value="xx" /> <add...
2
by: Scott Graupmann | last post by:
I'm having trouble getting the settings out of my app.config file in a c# project. I have put the file in the root of the project and in the bin output directory with the name "app.config" and...
4
by: feng | last post by:
..Net's .config file is supposed to replace the .ini files. That's all fine if all I need is to read from it. But what if I need both read and write? With .ini file, I can do that very easily with...
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: ...
6
by: yaron | last post by:
Hi all, I want to give a sample console application for the user with 2 configuration files. I want to give also a 2 .bat files for running the sample application, one for each configuration...
5
by: Sridhar | last post by:
Hi, I have created a project which contains classes to read the data from the database. This project has an App.Config file which contains the SqlConnection String. when this code is called from...
1
by: Todd Brewer | last post by:
I have an ASP.NET web site that uses a .NET dll. The DLL has a DataSet in it. Problem is, the DLL uses an app.config file (and worse yet, it uses the stupid settings.settings file, which in turn...
9
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.