XmlTextWriter 101
-
I'm new to the XML world and have been previously using INI type files in old DOS aps and latley in C++ for .NET. Now we're on to the world of C#. I know I can use XmlTextWriter, but the examples don't help too much. Let me set it up for you. The application will have lots of settings that the user can play with. For example, there will be a serial number (text data) and there will be some float data (like a float for the span adjustment of the device). I want to be able to save the contents of a text box to a XML file and read it back. I also will read/write from the target board. So, how you propose I do it? I can see several catagories of items to save, then several items under each catagory. The following C# code doesn't work because it doesn't like the "fi" in the second line: FileInfo fi = new FileInfo(saveFileDialog1.FileName); XmlTextWriter writer = new XmlTextWriter(fi); That's how I would have done in C++ prior to writing to an INI file. Any help will be great, but please be specific. I'm just getting started in XML! Kenny O'Dell Sr. R&D Software Engineer Mettler-Toledo Inc. Inman, SC
-
I'm new to the XML world and have been previously using INI type files in old DOS aps and latley in C++ for .NET. Now we're on to the world of C#. I know I can use XmlTextWriter, but the examples don't help too much. Let me set it up for you. The application will have lots of settings that the user can play with. For example, there will be a serial number (text data) and there will be some float data (like a float for the span adjustment of the device). I want to be able to save the contents of a text box to a XML file and read it back. I also will read/write from the target board. So, how you propose I do it? I can see several catagories of items to save, then several items under each catagory. The following C# code doesn't work because it doesn't like the "fi" in the second line: FileInfo fi = new FileInfo(saveFileDialog1.FileName); XmlTextWriter writer = new XmlTextWriter(fi); That's how I would have done in C++ prior to writing to an INI file. Any help will be great, but please be specific. I'm just getting started in XML! Kenny O'Dell Sr. R&D Software Engineer Mettler-Toledo Inc. Inman, SC
Hi, There isn't an
XmlTextWriter
constructor that takes aFileInfo
as a parameter. There's a choice of three constructors, it looks like you probably want to use this one:public XmlTextWriter(string filename, Encoding encoding);
Cheers Phil Hobgen barbari.co.uk Southampton, UK