On Mon, 30 Apr 2007 23:28:29 -0700, Jason Huang
<Ja************@hotmail.comwrote:
In my C# windows form application, I can write a dataset to an XML file.
But everything in that XML are String type.
Is is possible to write a dataset to an XML file, so that the DateTime
and Int is still DateTime and Int in the XML?
Sure. Just format the data into a string, using an appropriate format for
the information you want to save. For an int, this would probably be the
default ToString() behavior, unless you had some reason to make it look
different in the XML file. For a DateTime, you would use a format that
preserves the portions of the DateTime that are important to you.
When reading the XML back in, just use the Parse() methods to recover the
original data from the strings.
Finally, keep in mind that I've never used the built-in .NET XML handling
classes. Given that the project Settings property handles this sort of
thing for you, it's possible that the built-in .NET XML stuff has a way to
do this automatically rather than making you Format and Parse yourself.
Maybe someone else will point out a better way than the above.
Pete