473,320 Members | 2,052 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,320 software developers and data experts.

Accessing config files programatically

Hi chaps,

Can someone direct me to the necessary class that will allow me to write
information into my applications .config file? I know how to read
information but I'm sure there must be a way to write out to the config file
easily as well.

Also, my application doesnt actually have a config file created by default.
I thought the VS template would create one automatically but it doesnt. Is
it ok just to make one in the form:

MyApp.exe.config

Will that work?

Thanbks everyone

Simon
Nov 15 '05 #1
3 3427
The API only allows you to write from it.

In VStudio, you have to create a file called app.config (not
myapp.exe.config) in your project's base directory and you have to include
it into your projet (it will be included by default if you create it with
VStudio but not if you create it outside of Studio).
Then, when you compile your project, Studio will copy it to bin/Debug or
bin/Release depending on the config, and it will rename it MyApp.exe.config.

Also, don't try to create MyApp.exe.config directly into bin\Debug, it will
get overwritten every time you compile.

Bruno.

"Simon Harvey" <sh856531@microsofts_free_email_service.com> a écrit dans le
message de news:ua**************@tk2msftngp13.phx.gbl...
Hi chaps,

Can someone direct me to the necessary class that will allow me to write
information into my applications .config file? I know how to read
information but I'm sure there must be a way to write out to the config file easily as well.

Also, my application doesnt actually have a config file created by default. I thought the VS template would create one automatically but it doesnt. Is
it ok just to make one in the form:

MyApp.exe.config

Will that work?

Thanbks everyone

Simon

Nov 15 '05 #2
> The API only allows you to write from it.
Of course, I meant READ from it. I must be tired.

Bruno
Nov 15 '05 #3
The reason there's no API to write to it of course is that your app could be
running under lock-down mode -- no write access to Program Files etc. The
standard pattern is to look for a user-specific file (under Documents and
Settings ... Application Data), and if that can't be found, read the
application one.
"Bruno Jouhier [MVP]" <bj******@club-internet.fr> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
The API only allows you to write from it.

In VStudio, you have to create a file called app.config (not
myapp.exe.config) in your project's base directory and you have to include
it into your projet (it will be included by default if you create it with
VStudio but not if you create it outside of Studio).
Then, when you compile your project, Studio will copy it to bin/Debug or
bin/Release depending on the config, and it will rename it MyApp.exe.config.
Also, don't try to create MyApp.exe.config directly into bin\Debug, it will get overwritten every time you compile.

Bruno.

"Simon Harvey" <sh856531@microsofts_free_email_service.com> a écrit dans le message de news:ua**************@tk2msftngp13.phx.gbl...
Hi chaps,

Can someone direct me to the necessary class that will allow me to write
information into my applications .config file? I know how to read
information but I'm sure there must be a way to write out to the config

file
easily as well.

Also, my application doesnt actually have a config file created by

default.
I thought the VS template would create one automatically but it doesnt. Is it ok just to make one in the form:

MyApp.exe.config

Will that work?

Thanbks everyone

Simon


Nov 15 '05 #4

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

Similar topics

2
by: Anatoly | last post by:
I'm trying to use VB.NET's 2003 ConfigurationSettings.AppSettings.Set() method of updating values but getting error "Collection is read-only". How can I change values of keys in the App.config...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
0
by: Roger Helliwell | last post by:
Hey all, Our web app (.NET 2.0 beta 1) uses the web.config to store site-wide settings. Most of these settings are in the <appSettings> section and getting at them at runtime is a snap by using...
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
4
by: Khalique | last post by:
I have built a web service whose purpose is to copy files from a secure place to client machine and vice versa. The problem I am having is perhaps related to permissions and access rights. For...
20
by: tomerfiliba | last post by:
hey i've been seeing lots of config-file-readers for python. be it ConfigObj (http://www.voidspace.org.uk/python/configobj.html) or the like. seems like a trend to me. i came to this conclusion...
2
by: Nathan Sokalski | last post by:
When I put my *.ascx files in the same directory as Web.config and my user controls are registered in Web.config it gives me an error. Putting my *.ascx files in another directory is not hard, but...
3
by: Jeremy Chaney | last post by:
It appears that my user.config file got corrupted causing my "InitializeComponent" routine to throw the exception "Root element is missing." when I start my app. I figure I can just go into...
1
by: Carmen Sei | last post by:
the C++ way of accessing a library is using #include, consider the following include herarichy: main.cpp -Demo.h -Config.h -Gconfig.h -ConfigDef.h the above shows main.cpp include -Demo.h and...
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...
1
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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.