Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XML Version of INI File

Posted on 2006-11-18
3
Medium Priority
?
230 Views
Last Modified: 2010-04-23
Hi All,

I require an XML version "ini" file...

Does someone have some code in which I can handle the same sort of functions that the old ini files used....such as add and delete section, key and value.

I am trying to stay away from the good old ini files and new to .Net and XML so bear with me.

Thanks
0
Comment
Question by:nzfire
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 17971491
Hi nzfire,

see an article I wrote in May 2003 from http://emoreau.s2i.com/

Cheers!
0
 
LVL 5

Expert Comment

by:DEEPESH
ID: 17971595
i think you should use config file if possible.

As it is quite easy to read and write app file through system.configuration. Just make application section in your config file
foor example
    <appSettings>
        <add key="a" value="a" />
        <add key="b" value="b" />
        <add key="c" value="cd" />
    </appSettings>



For reading
        Dim config As System.Configuration.Configuration
        config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
        Dim value As String
        value = ConfigurationManager.AppSettings(TextBox1.Text)
        MsgBox(value)

For writing
        Dim config As System.Configuration.Configuration
        config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)

        '// Add an Application Setting.
        config.AppSettings.Settings.Remove(TextBox1.Text)
        config.AppSettings.Settings.Add(TextBox1.Text, TextBox2.Text)

        '// Save the changes in App.config file.
        config.Save(ConfigurationSaveMode.Modified, True)
        config.SaveAs("C:\Documents and Settings\Administrator\Desktop\DOTNETAPP\WriteConfig\WriteConfig\app.config", ConfigurationSaveMode.Minimal, True)
        '// Force a reload of a changed section.  
        ConfigurationManager.RefreshSection("appSettings")
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17972941
if you are looking into which methods to use to create sections and read values from XML files, i recommend you browse the MSDN and look for XPathNavigator and XMLDocument.
NY
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question