Guest User

Untitled

a guest
Jun 1st, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. DataTable dt = new DataTable();
  2. DataSet ds = new DataSet();
  3. string fileName = @"izdelia.xml";
  4. dt = ((DataTable)dataGridView1.DataSource).Copy();
  5. ds.Tables.Add(dt);
  6. System.IO.FileStream myFileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
  7. //System.Xml.XmlTextWriter myXmlWriter = new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
  8. System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument(ds);
  9. xmlDoc.DataSet.EnforceConstraints = false;
  10. System.Xml.XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
  11. xmlDoc.PrependChild(xmlDec);
  12. System.Xml.XmlWriter xmlWriter;
  13. xmlWriter = new XmlTextWriter(myFileStream, System.Text.Encoding.UTF8);
  14. xmlDoc.WriteTo(xmlWriter);
Add Comment
Please, Sign In to add comment