473,770 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.confi g

Will that work?

Thanbks everyone

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

In VStudio, you have to create a file called app.config (not
myapp.exe.confi g) 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.confi g.

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

Bruno.

"Simon Harvey" <sh856531@micro softs_free_emai l_service.com> a écrit dans le
message de news:ua******** ******@tk2msftn gp13.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.confi g

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******@clu b-internet.fr> wrote in message
news:%2******** ********@tk2msf tngp13.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.confi g) 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.confi g.
Also, don't try to create MyApp.exe.confi g directly into bin\Debug, it will get overwritten every time you compile.

Bruno.

"Simon Harvey" <sh856531@micro softs_free_emai l_service.com> a écrit dans le message de news:ua******** ******@tk2msftn gp13.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.confi g

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
9559
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 file programatically? Here is my code: Imports System.Configuration Imports System.Collections.Specialized
1
3139
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 elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such as: 1)
0
967
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 ConfigurationSettings.AppSettings for example However, there are some ASP.NET settings that have their own sections in the web.config that I want to get at as well. I've played around with the GetConfig() method (code below) but so far no luck....
0
2266
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 updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization involves reading and writing some text and xml files using simple streamreader and streamwriter...
4
3781
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 testing purposes, the secure place is setup on the client machine. The client (window app) calls the web service (on a different machine) and connects successfully to the web service. However, when client calls a method that copies the file from...
20
2624
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 a long time ago: YOU DON'T NEED CONFIG FILES FOR PYTHON. why re-invent stuff and parse text by yourself, why the interpreter can do it for you? and anyway, i find this a very ugly format:...
2
1823
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 it can cause another annoyance: relative directories. For example, that means that I need to write code to add a ../ to the beginning of all relative directories used in the user controls, which can be a real pain, especially if the directory is...
3
10526
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 Explorer and delete the file to get things working again, but I'd rather just catch the exception and resolve the error programatically. I tried "Properties.Settings.Default.Reset();" but that just throws the exception too. Does anyone know how I can...
1
1400
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 Demo.h include -> Config.h ... and so on then basically, main.cpp had inheritan everything of the 4 header files (Demo.h, Config.h, Gconfig.h, ConfigDef.h)
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7456
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.