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
 
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.
 
Back
Top