Saving to files - XML - C#

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

Guest

I am fairly new to the C# world, and I am seeking a little guidance about
saving user information. Consider the following:

I have several windows which contain settings for an embedded target. The
user will either load the settings from a file (which is why I am writing
this question), or type them in manually, or upload them from the target.

What I need to know is how to create a XML file. In past projects, we
created an INI type file, but now we want to do XML. I am writing this app
in C#.

If you have pointers or examples, I would appreciate it. The Knowledge base
and help files are not very helpfull to someone who is so new to the tool.
 
The following is the next problem:

FileInfo fi = new FileInfo(saveFileDialog1.FileName);
XmlTextWriter writer = new XmlTextWriter(fi);

That does not work. That is how I got it to work with the INI files in C++.
So, I have an OpenFileDialog that returns stuff, how do I hook it up to the
XmlTextWriter? It obviously does not just want to see the item "fi" above.

I hate knowing exactly what you want to do but not how. Frustrating.
 
Use the FileStream class instead of the FileInfo class. Remember to close
the stream once you have finished with the resource.
 
Back
Top