I'm writing Xml file in asp.net now my problem is that if i delete newly created xml file then this code is working actually i'm using stream writer still it is showing file exists it means that previous file is not appended or detroyed so plz tell me the soln This code is Asp.net & C# This is my code Plz check and correct it send me it soon stw = new StreamWriter("C:\\Myxml\\Items.xml",true); xtw = new XmlTextWriter(stw); //(stream, System.Text.Encoding.ASCII); //(stw); xtw.WriteStartDocument(); xtw.WriteStartElement("ItemData"); xtw.WriteStartElement("ItemsData"); xtw.WriteStartElement("Item"); xtw.WriteElementString("ItemNo", TextBox1.Text); xtw.WriteElementString("ItemName", TextBox2.Text); xtw.WriteElementString("ItemCost", TextBox3.Text); xtw.WriteEndElement(); xtw.WriteEndElement(); xtw.WriteEndDocument(); xtw.Flush(); ClientScript.RegisterStartupScript(GetType(), "Hello", "<script>alert('Data Written to Xml file Successfully...')</script>"); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; TextBox3.Text = string.Empty; xtw.Close();
thanks in advance
|
| Author: M. Irfan 06 Jul 2008 | Member Level: Gold | Rating: Points: 4 |
If you dont want to use the previous xml file then delete it using
if file exist then delete the file
other way is just open the xml file using xml document and append your new xml node into it.
Choose what is feasible for your application.
----------------------------------------------- thanks
|