473,591 Members | 2,891 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 5320
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
3006
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
3816
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
1964
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
1562
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
3435
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
5337
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
1978
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
1667
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
3239
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
3432
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
7871
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
8236
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...
0
8366
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
7995
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
8227
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6642
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...
0
3851
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...
1
2379
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
1
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.