hey all,
i want to store data in file....not in database......how this can be implemented
hey all,
i want to store data in file....not in database......how this can be implemented
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Blocked AccountPosted Jan 30, 2008, 4:39 AM
You can use the XML file for storing the data. this is the code for writing in the XML file.
private void CreatePreviewXMLFile()
{
string FileName = "PageTitle.xml";
XmlDocument xmlDoc = new XmlDocument();
XmlTextWriter xmlWriter = new XmlTextWriter((FileName), System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
xmlWriter.WriteStartElement("PageTitle");
xmlWriter.Close();
xmlDoc.Load(FileName);
XmlNode Root = xmlDoc.DocumentElement;
XmlElement Page = xmlDoc.CreateElement("Page");
Page.SetAttribute("ID", PageNumber.ToString());
XmlElement Id = xmlDoc.CreateElement("Id");
XmlElement Title = xmlDoc.CreateElement("Title");
XmlElement PageUrl = xmlDoc.CreateElement("PageUrl");
XmlText textId = xmlDoc.CreateTextNode("Hello");
XmlText textTitle = xmlDoc.CreateTextNode("Hello4");
XmlText textPageUrl = xmlDoc.CreateTextNode("Hello4");
textId.Value = PageNumber.ToString() ;
textTitle.Value = ViewState["PageTitle"].ToString();
textPageUrl.Value = txtPageName.Text ;
Root.AppendChild(Page);
Page.AppendChild(Id);
Page.AppendChild(Title);
Page.AppendChild(PageUrl);
Id.AppendChild(textId);
Title.AppendChild(textTitle);
PageUrl.AppendChild(textPageUrl);
xmlDoc.Save(FileName);
}
Happy Coding!!