can't read config file

D

Dica

i've followed the instructions i found here about how to add a config file
to my applicaiton:
http://www.c-sharpcorner.com/Code/2003/Nov/CreateUseConfigFiles.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?
 
G

Guest

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.
 
D

Dica

Chris Ballard said:
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
 
R

Richard Blewett [DevelopMentor]

Dica said:
i've followed the instructions i found here about how to add a config file
to my applicaiton:
http://www.c-sharpcorner.com/Code/2003/Nov/CreateUseConfigFiles.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
 
G

Guest

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!
 
D

Dica

"Richard Blewett [DevelopMentor]" <richard at nospam dotnetconsult dot co
dot uk> wrote in message news:%[email protected]...
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.
 

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