xml config file...

hello,
I ve a Windowsapplication with a configuration file app.config... (it's in
xml)

code app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name = "MyNameValueSection"
type="System.Configuration.NameValueSectionHandler" />
</configSections>
<MyNameValueSection>
<add key="MyKey" value="MyValue" />
</MyNameValueSection>
<appSettings>
<add key="test" value="MeinInhalt" />
</appSettings>
</configuration>

I want to change in my c# programm the values of "test" and "MyKey"...
any information or samples would be helpful
thanx a lot in advance
Andrea


0
8/7/2003 7:20:35 AM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
806 Views

Similar Articles

[PageSpeed] 20

Andrea,

The .NET Framework does not let you modify config files via the classes in
System.Configuration.

If you have to modify them, then you can do so by hand with the XmlDocument
class or with the Configuration Management Application Block [0].

However, modifying the .config files has its own set of issues that may
collide with the development guidelines for windows applications.User
specific settings, for example should not be stored in the application
directory (where app.config resides), but in the user's folder \documents
and settings\username\LocalSettings\<blablabla>

HTH,
Christoph Schittko
Software Architect, .NET Mentor
MS MVP XML .NET

[0]
http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=01875f69-9358-437b-a8ae-fa4bf2e3080f
"andrea" <lener_andrea@hotmail.com> wrote in message
news:eeLUvSLXDHA.1280@tk2msftngp13.phx.gbl...
> hello,
> I ve a Windowsapplication with a configuration file app.config... (it's in
> xml)
>
> code app.config:
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> <configSections>
> <section name = "MyNameValueSection"
> type="System.Configuration.NameValueSectionHandler" />
> </configSections>
> <MyNameValueSection>
> <add key="MyKey" value="MyValue" />
> </MyNameValueSection>
> <appSettings>
> <add key="test" value="MeinInhalt" />
> </appSettings>
> </configuration>
>
> I want to change in my c# programm the values of "test" and "MyKey"...
> any information or samples would be helpful
> thanx a lot in advance
> Andrea
>
>


0
8/7/2003 12:53:34 PM
Reply:

Similar Artilces:

XML Header
Hi, I have some XML doc loaded in a C# Web Service. XmlDocument doc = new XmlDocument(); doc.LoadXml(myDoc); Code Missing to manipulate header (I would like to replace or manupulate all these XXXXX): <mso-XXXXXX productversion="XXXXXX"> <mso-application progid="XXXXX"?> doc.Save(myNewDoc); Any idea on how to access and manipulate data within the doc header? Thanks vbdev vb6dev2003 wrote: > I have some XML doc loaded in a C# Web Service. > XmlDocument doc = new XmlDocument(); > doc.LoadXml(myDoc); > > Code Missing to manipulate header ...

how to compare two excel files
i would like to know how to compare two excel files. is there any tool for that? in addtion is there any way to maintain several versions of the same file with easy way to have diff between them? thanks, -- Miri Tz. Hi Miri, There are a number of programs out in the market that provide more complex comparision. Otherwise you could simply make a new sheet and copy the following formula into A1: =if('[book1.xls]sheet1'!a1='[book2.xls]sheet1'!a1,"","<<<") anotherway to do it is to run the following you need to set up the workbook and workshee...

Identify files on two diff spreadsheets
I need help... I have two spreadsheets, named 2008 and RS, both with file numbers in column A1 with different information in the other columns. I need to know if the files on the spreadsheet "RS" are on the spreadsheet "2008" and if so, then put a "1" in column "U" next to that file on the "2008" spreadsheet. I tried the vlookup function, but couldn't quite figure it out. Please help. Thanks in advance. Try this formula in column U of the 2008 sheet: =IF(COUNTIF(RS!A:A,'2008'!A1)>0,"U","") ...

Read XHTML into XML
Hi all, I need to read/parse XHTML aspx pages and look for certain tokens and content. How can I use a XmlTextReader for this? If not, any other ideas? Thanks in advance, JA Reyes. Jose Antonio Reyes wrote: > I need to read/parse XHTML aspx pages and look for certain tokens and > content. How can I use a XmlTextReader for this? If not, any other ideas? If the pages are well-formed XHTML then it is possible to use XmlReader (in .NET 2.0/3.0) or XmlTextReader (in .NET 1.x) to parse the XHTML documents. You can also use the other XML APIs .NET provides so using XPathNavigator and/o...

Sync mail files
I have a small network of 3 computers. Can I syncronize the Outlook.pst file so that any of the 3 machines will have access to all of the mail folders? Any clues will be welcomed. Gill gaffer <gaffergill@bellsouth.net> wrote: > I have a small network of 3 computers. Can I syncronize the > Outlook.pst file so that any of the 3 machines will have access to > all of the mail folders? See if something here helps: http://www.slipstick.com/outlook/sync.htm -- Brian Tillman ...

How to invoke the xml editor?
I installed vs2005 on a new xp pro machine, and installed everything except C++. When I click on a file with a ".xml" extension it is opened with IE. When I click file/Edit with XML Editor, it opens it with Notepad. If I click File/Open With and select XML Editor, it opens it with IE. So, where is the xml editor? Can it be invoked from withing VS? Where? Bill * billsahiker@yahoo.com wrote in microsoft.public.dotnet.xml: >I installed vs2005 on a new xp pro machine, and installed everything >except C++. When I click on a file with a ".xml" extension it is >opened ...

Corrupted .pst file !!!?!?! Help
Hi, My outlook.pst is corrupted. Tha'ts why I cannot start me outlook 2003 (see my other post here) I used the inbox repair tool (SCANPST.EXE) but it doesn't work, I got the following message: "An unexpected error prevented access ti this file. Use scandisk to check the disk for errors and then try using the inbox repair tool again" Outlook is closed and I already scanned my hard disk using scandisk, and there are no error. The error really seems to come for the corrupted pst file. Related to the file corruption, When I tried to copy the outlook.pst file to an...

windows32/config/system during install
Hi I am installing XPHome and get this message after the first reboot Cannot access the file windows32/config/system. Reboot to the install CD and type R to repair. How do I get around this? thanks Daniel "Daniel" <noone@nowhere.com> wrote in message news:%23efxvgR3KHA.3728@TK2MSFTNGP06.phx.gbl... > I am installing XPHome and get this message after the first reboot > > Cannot access the file windows32/config/system. > Reboot to the install CD and type R to repair. > > How do I get around this? Just boot the Install CD and type R ...

Installing Money 2003 on new PC..what files to copy from old PC?
I have purchased a new PC (Windows XP). To move Money 2003 to the new one, I assume that I would just install Money from the original CD. My question is, what files do I need to copy from my old PC? (old PC was Windows 98) Thanks, Tommy Flynn Your .MNY file(s). And you will need to move most of the Money Tools|Options settings by hand. Worst case for these is printer check alignment settings. "Tommy Flynn" <tflynn@mindspring.com> wrote in message news:bfbff0$fjf$1@slb9.atl.mindspring.net... > I have purchased a new PC (Windows XP). To move Money 2003 to the new one...

show XML schema and values
I have an XML document that looks like the following: <record> <Field1>value1</Field1> <Field2>value2</Field2> <Field3>value3</Field3> </record> What I'm aiming to do is to show the data in a report as in the following example: record: Field1 value1 Field2 value2 Field3 value3 The "Field1-3"-elements can have any name, so I'm trying to get a table that has in one result column the element name, and in the second colum...

File sharing
Hi, I have a client with two machines running Mac OS X 10.3.6, and MS Office 2004 with SR1, and both machines have file sharing enabled. If machine1 has a file on its hard disk opened called file1.xls, and machine2 tries to open the same file I thought that machine2 would only be able to access the file read-only, and be told this. However what I am seeing is that machine2 can open the file, make changes, and save the changes but if machine1 makes changes and saves their version machine2's changes are lost. Shouldn't machine2 be told that they can only open the file read-only? Thank...

Offline synch using XML web-services
This is a bit long-winded. Can somebody read thru these 2 use cases, and tell me if it is feasible ? :- Use Case : Replication before Offline Synch Scenario 1 : Oracle Server , MSDE client 1. User clicks on 'Go Offline'. System creates a MSDE SQL database in laptop (client), gets the schemas of the tables in Oracle, creates corresponding tables in client's MSDE SQL (mapping Oracle datatypes to SQL datatypes). 2. Offline replication program reads in the tables of the server into a typed datasets, converts the typed datasets into XML, and stores the XML in the client. (XML serial...

XML Serialization ... how to truncate <?xml...
While xml serializing object how can I truncate <?xml ...?> this line alone? I need to send the serialized xml data to a web method ... since SOAP already have <?xml tag there was some confusion Any help would be greatly appreciated Thank you Regards Raj Raj wrote: > While xml serializing object how can I truncate <?xml ...?> this line alone? Serialize to an XmlWriter created with XmlWriterSettings where you set OmitXmlDeclaration to true. -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ ...

TMP files #3
Since getting a new pc, any attempt to save a file in Excel, instead saves to a TMP file. I get no errors, and I can open the file again fine, but my disks are slowly filling up with TMP file instead of spreadsheets. Any ideas? Jono Although you didn't get an error message this article describes problems with saving files and being left with tmp files. It may provide some insight: http://support.microsoft.com/default.aspx?scid=kb;en-us;103329&Product=xlw -- Jim Rech Excel MVP "jono" <anonymous@discussions.microsoft.com> wrote in message news:1d65401c423a1$29e...

Outlook 2002/Exchange Server
We have started inserting HTML signatures into e-mails, instead of standard text signatures. The signature looks like a rolodex card with contact info and adds about 7KB. An image, which I assume is treated as embedded, is the border around the "card." The only other image is our logo, which is a direct link to a GIF on our website, not embedded. However, I have recently become aware of potential file size problems due to how Outlook handles e-mail attachments. We typically send e-mails with Word document attachments internally to multiple recipients. When they are done reviewi...

Log files #5
Here's the situation 1. Hard disk died (Single IDE) 2. Have a sucessful ntbackup on a remote server 3. Rebuilt Win Server 2000 with new disk using previous server name 4. Restored System State from ntbackup 5. Reinstall Exchange 2000 SP3 6. Restored Mailbox Store and Public Folder Store. 7. The default Mailbox Store and Public Folder Store would not mount. It would let me create and mount a new one, though. 8. Searched endless articles to find out why Mailbox Store fail to mount but no avail, so created a new Mailbox Store. 9. Deleted all users' Mailboxes ...

String to xml document
Hi there, I was hoping someone can help me with a little problem I can't seem to find any answers to. I've got a form wich will be posted. On receiving the post I would like to parse a formvar to a xml document. The contents of this formvar (string) will be a valid xhtml document. Can someone give me a startertip (or more :-)) on how to achieve this? tnx in advance, James van der Veen Sjeems wrote: > I was hoping someone can help me with a little problem I can't seem to find > any answers to. > > I've got a form wich will be posted. On receiving the p...

Beginner of XML
I am a beginner of XML. I want to group some files together with a xml file. (it includes a text file, and an image file and a video file) Can someone show me some guidelines? Please help. ...

Valid xml to read from an xml file?
I'm using vb.net, i get an error at the reader line saying the remote server can't be found. Is the below even valid? dim reader as XmlTextReader reader = new XmlTextReader ("http://www.mysite.com/my.xml") do while (reader.Read()) 'do some action here response.write(reader) loop thanx chumley XmlTextReader uses System.Net.WebRequest under the covers -- see if you can figure out how to create a connection that way. Usually there's some proxy server information missing that you can enable if you use WebRequest directly, and then pass the result of GetResponse()...

Can I restore a file that I have accidentally saved over?
Hi there, I was typing up a document and wanted to check how many words i had typed. Clicked the wrong button by mistake and auto selected the whole document. What made it worse was that my brother was next to me being a pain and saved the document, when I came back he panicked as it was all gone so he rebooted the computer. I have tried using windows restore to turn back time but the document remains as what my brother saved it as, "Z". What can i do? i need it back to normal asap HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!! ME!!!!! Was the document saved previously with...

Creating and Organization Chart from and excel file
I was able to create an org. chart awhile ago and now when I try to use the org. chart wizard and select the excel file I get an error "cannot read names". I have excel and visio 2003. Can anyone help???? I want to include 4 fields from from excel file (name, title, department, reports_to). Help! Have you tried creating an Excel file recently? Perhaps there's an issue with your existing Excel file. I'd try generating a dummy file using the wizard, and then try importing it iback nto a new Visio file using the wizard. If that works, then you may want to cut / pas...

windat files I have a nagging problem with attachments to my emails that have the the winmail.dat attachnents
I have a nagging problem with attachments to my emails that have the ..winmail.dat format. my hotmail email will not open these attachments. I have to save the attachment to my desktop and then use a windat reader to open the file,which takes so much time. isn't there any other way to open these attachments? thankyou. -- Richard K Mahan Sr "Imagination is the Father of Creativity" -- Richard K Mahan Sr "Imagination is the Father of Creativity" "Richard Mahan" <dmachen35@comcast.net> wrote in news:QYidnQUtfOjpTVvbnZ2dnUVZ_q6hn...

Example eConnect XML documents
MSDN says the following: Installing eConnect schema When you include the schemas component of the eConnect install, the installer places schema files in a schemas folder on your computer. The following schema resources are available: The install places the .xsd schema files in the directory c:\Program Files\Microsoft Great Plains\eConnect9\XML Schema\Incoming XSD Individual Schemas. The files in the directory contain the schema for each eConnect XML document. The install places a file named eConnect.xsd that contains the schema definition for all eConnect XML documents. The install typicall...

In which header file is VK_OEM_PLUS defined?
In MSDN, it says that VK_OEM_PLUS is a defined key (constant? ). But I can't find the the header file in which VK_OEM_PLUS is defined. "Fei Xu, or Flying Xu" <FeiXuorFlyingXu@discussions.microsoft.com> wrote in message news:BA1B6413-96DF-44BA-A1B6-A972DFC50F91@microsoft.com... > In MSDN, it says that VK_OEM_PLUS is a defined key (constant? ). > But I can't find the the header file in which VK_OEM_PLUS is defined. Based on my PSDK install, it appears in 'WinUser.h'. -- Jeff Partch [VC++ MVP] ...

Saving DataSet as XML in ADO format using VB.NET
Hi, I am trying to convert a lot of web reports from ASP/VB to ASP.NET/VB.NET. I would like to save my dataset in XML and then use XSLT to transform the XML. The catch is I would like to have the XML in the format that ADO uses versus the default format in which ADO.NET uses. Currently, I am using ADO within .NET, but I am concerned about the performance and it might improve if I used the native data providers for .NET. I am not sure if I am missing something but how do I save the .NET DataSet to XML in the OLD ADO format? Thanks for you help in advance and it is most appreciated. In the ...