473,800 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Config.xml file read and write ?

i have a setting form for my program and wish to allow the setting to
be saved and reopened to the last set setting on program startup..
lets say i have a xml file like this :

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<appSettings>
<add key="test" value="My Test String"
/>
</appSettings>
</configuration>

[code:1:9a6bbbbe ac]

private void button1_Click(o bject sender, System.EventArg s e)
{

//here i put what code ??

}

[/code:1:9a6bbbbe ac]

how do a get the app to save any new settings to this xml file and
also how do i load the setting on program startup ?

Thanks

MrXs

Nov 16 '05 #1
1 5330
In your config file,specify the name of a seperate settings file (or use a
default name). If the app is run by multiple users, and they each need
their own settings, make sure you store the settings file in their local
"Documents and Settings" folder, and not in the app directory.

Have your app deserialize the setting file when you start up, and
reserialize it when you shut down. XML of course.

Let the config file be application config, not user settings. Most .NET
apps do this or a form of this for storing settings, rather than changing
the config file itself.

--- Nick

"MrXs" <Mr******@hotma il-dot-com.no-spam.invalid> wrote in message
news:41******** **@Usenet.com.. .
i have a setting form for my program and wish to allow the setting to
be saved and reopened to the last set setting on program startup..
lets say i have a xml file like this :

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<appSettings>
<add key="test" value="My Test String"
/>
</appSettings>
</configuration>

[code:1:9a6bbbbe ac]

private void button1_Click(o bject sender, System.EventArg s e)
{

//here i put what code ??

}

[/code:1:9a6bbbbe ac]

how do a get the app to save any new settings to this xml file and
also how do i load the setting on program startup ?

Thanks

MrXs

Nov 16 '05 #2

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

Similar topics

13
3023
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a python datastructure (a dictionary?) 4) not requiring any heavy libraries needed (I am distributing my proggie as a py2exe executable and do not want to bloat the size) can you guys suggest some format for this? thanks, max
4
3831
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply* access config files. This is version 3, which is a big overhaul. It extends ConfigObj to reading config files with sections and various other simplifications. I find ConfigObj extremely easy to use and use it for reading config files and data...
4
1975
by: V.Boomessh | last post by:
Hai All I am developing a VB application in .NET. I read a encrypted text file which contains details of SQL Server name, SQL DBName etc... for DB Connection and i prepare a connection string for global use I also read from a book, that the connection string can be placed in "appname.exe.config" file for windows application. Is there any way to write/append key value pairs into the config file at run time Thanks V.Boomessh
4
1575
by: UJ | last post by:
Is there a way to write into the .config file? In other words treat it like a .ini file. (I may be confused on what the exact nature of the .config file may be.) I can read from it fine but would also like to be able to write to it. TIA - Jeff.
3
3457
by: Simon Harvey | last post by:
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:
1
5363
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; Anybody able to give me idea how-to read by C# element which I add to the machine.config into the new single section?
16
1996
by: Timm | last post by:
I'm trying to use ASP objects (basically formed and populated based on Web.Config settings) and I want to use them in a different non-asp program with minimal reprogramming. So, my question is how do I mock up what ASP does to read the Web.Config file? I've tried messing around in the System.Configuration library and haven't been able to find anything from taking a quick look at the objects and their methods (for the goal of populating the...
4
1673
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 standard API. But is there API for writing the .config files? I know we can treat .config file as a regular XML file and using XML API to write to it, but is there API for writing to .config file just like we read from it? Thanks.
17
3256
by: Fred Nelson | last post by:
Hi: I have written several web applications that obtain their connection strings from the web.config file. This is very easy to use and it makes it easy to move an app from development into production. I'm in the process of writing a site that will have lots of traffic so I'm trying to save resources everyplace that I can. My question is - do the web.config app settings get loaded once when the
11
3453
by: TARUN | last post by:
Hello All I need to ask about the configuration file in .NET, There are Two config File 1. Web Config 2. Machine config I understand the the usage of Web config , but not able to understand the usage of Machine config. I read in the article that you can also write your database connection string in Machine Config
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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
10507
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10255
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,...
1
7582
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
6815
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
5473
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
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.