Last post Nov 21, 2010 12:21 PM by sandrin0
Nov 17, 2010 01:07 PM|sandrin0|LINK
I got an application that opens a xml file and writes to it and saves it to another (fixed) file name.
But my question is: Is there a way to save the Xml file to a random number or the input of a textbox?
I am using the XmlTextWriter in a Form app and the language is C#.
xml .Net C#
Nov 17, 2010 02:31 PM|jackym|LINK
you can use a StringWriter to store the output temporarily, then save the string to a text box or other controls.
StringWriter sw = new StringWriter();
XmlTextWriter xtw = new XmlTextWriter(sw);
//do anything you want to do with XmlTextWriter
textBox.Text = sw.ToString(); //this is the xml document you created.
Nov 18, 2010 10:12 PM|Decker Dong - MSFT|LINK
Is there a way to save the Xml file to a random number……
Maybe you want your name is randomized???
If yes, do this please:
XmlTextWriter writer = new XmlTextWriter("C:\\"+Guid.NewGuid().ToString()+".xml");
Or you can use Random r = new Random(DateTime.Millisecond);
int i = r.Next(0,1000);
to create a random number and substitute Guid with i.
Nov 21, 2010 12:21 PM|sandrin0|LINK
Thanks for your replies it works.