C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Xml File in Asp.net


Posted Date: 06 Jul 2008      Total Responses: 1

Posted By: sachin       Member Level: Silver     Points: 1



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





Responses

Author: M. Irfan    06 Jul 2008Member Level: GoldRating:     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



Post Reply
You must Sign In to post a response.
Next : Transferring data from 1 list box 2 another on button click!
Previous : excel sheet
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use