Read/write simple XML

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am new to .net, VS, and C#. I would like my app to be able to read and write to a very simple XML file. Kind of like an older app would read/write to an INI file.

How do I code this?

I suspect there is a wizard or something that would create the code, but I don't know my way around VS. Is there an online (free) tutorial for learning the IDE? I am working my way through a turorial on the C# language, but it tells me nothing about the IDE.

Thanks,
Jon
 
The simplest way is probably going to actually be through XML
Serialization. ie have a class that stores the information that you want
in the XML file, and use .NET to serialize/deserialize it to XML.

For more info, take a look at http://www.developerfusion.com/show/3827/

Cheers,
 
Hi,

..NET uses .config files that are similar to INI files, unfortunately these
are read-only, at least in the current version
of the framework. If your program is called myapp.exe, then the config is
called myapp.exe.config and resides in
the same folder as the exe. Using the IDE, add a file called app.config to
the project. This file is automatically
renamed and placed in the Debug/Release folder when you build your
application.
Check out "ConfigurationSettings.AppConfig".

Microsoft has released a number of "application blocks", these are
classes/components that solve common programming problems,
including exeption handling, data access, and configuration settings. For
more information do a search on MSDN for
"Application blocks", at the time of writing this I got several "page not
found", so they might be doing something.

Another option is to create a custom class to hold your settings, then use
the XmlSerializer class to serialize/deserialize the data to XML.
This solution uses reflection and imposes some requirements on the classes
beeing serialized.
Check out the documentation on XmlSerializer.


Hope this helped

Chris


Jon said:
I am new to .net, VS, and C#. I would like my app to be able to read and
write to a very simple XML file. Kind of like an older app would read/write
to an INI file.
How do I code this?

I suspect there is a wizard or something that would create the code, but I
don't know my way around VS. Is there an online (free) tutorial for learning
the IDE? I am working my way through a turorial on the C# language, but it
tells me nothing about the IDE.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top