Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DataTable dt = new DataTable();
- DataSet ds = new DataSet();
- string fileName = @"izdelia.xml";
- dt = ((DataTable)dataGridView1.DataSource).Copy();
- ds.Tables.Add(dt);
- System.IO.FileStream myFileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
- //System.Xml.XmlTextWriter myXmlWriter = new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
- System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument(ds);
- xmlDoc.DataSet.EnforceConstraints = false;
- System.Xml.XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
- xmlDoc.PrependChild(xmlDec);
- System.Xml.XmlWriter xmlWriter;
- xmlWriter = new XmlTextWriter(myFileStream, System.Text.Encoding.UTF8);
- xmlDoc.WriteTo(xmlWriter);
Add Comment
Please, Sign In to add comment