System.Data.DataSet.WriteXml C# (CSharp) Method

WriteXml() public method

public WriteXml ( string fileName, XmlWriteMode mode ) : void
fileName string
mode XmlWriteMode
return void
        public void WriteXml(string fileName, XmlWriteMode mode)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.WriteXml|API> {0}, fileName='{1}', mode={2}", ObjectID, fileName, (int)mode);
            XmlTextWriter xw = new XmlTextWriter(fileName, null);
            try
            {
                xw.Formatting = Formatting.Indented;
                xw.WriteStartDocument(true);
                if (xw != null)
                {
                    // Create and save the updates
                    if (mode == XmlWriteMode.DiffGram)
                    {
                        new NewDiffgramGen(this).Save(xw);
                    }
                    else
                    {
                        // Create and save xml data
                        new XmlDataTreeWriter(this).Save(xw, mode == XmlWriteMode.WriteSchema);
                    }
                }
                xw.WriteEndDocument();
            }
            finally
            {
                xw.Close();
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }

Same methods

DataSet::WriteXml ( Stream stream ) : void
DataSet::WriteXml ( Stream stream, XmlWriteMode mode ) : void
DataSet::WriteXml ( TextWriter writer ) : void
DataSet::WriteXml ( TextWriter writer, XmlWriteMode mode ) : void
DataSet::WriteXml ( XmlWriter writer ) : void
DataSet::WriteXml ( XmlWriter writer, XmlWriteMode mode ) : void
DataSet::WriteXml ( string fileName ) : void

Usage Example

Beispiel #1
1
        public static void SaveDataSetAsXml(DataSet set, string fileName)
        {
            string file = Regex.Replace( fileName, extPattern, fileName );
             fileName = VerifyFileExt( fileName, ".xml" );

             set.WriteXml( fileName );
             set.WriteXmlSchema( file + ".xsd" );
        }
All Usage Examples Of System.Data.DataSet::WriteXml