Question Prevent overwriting when using DataTable.WriteXml?

digitaldrew

Well-known member
Joined
Nov 10, 2012
Messages
167
Programming Experience
Beginner
Is it possible aside from using something else like stremwriter? To my understanding anytime you use DataTable.WriteXml it will re-write the document and overwrite everything..

My code..
VB.NET:
            Dim xDS As New Settings
            Dim xRow As Settings.MainRow
            xRow = xDS.Main.NewMainRow
            xRow.username = txtUser.Text.Trim()
            xDS.Main.AddMainRow(xRow)
            xDS.WriteXml(Form1.MySettings, System.Data.XmlWriteMode.IgnoreSchema)

Thanks in advance!
 
For "append" you would have to read in the data from existing xml to DataTable/DataSet, make your changes/additions, then write out the complete new xml file from DataTable/DataSet.
The alternative would be to handle data as xml, where you opened the existing xml document using any of the .Net xml tools, modified it from you current DataSet data, and saved the new xml file.
 
Back
Top