本文整理汇总了C#中System.Data.DataTable.WriteXml方法的典型用法代码示例。如果您正苦于以下问题:C# System.Data.DataTable.WriteXml方法的具体用法?C# System.Data.DataTable.WriteXml怎么用?C# System.Data.DataTable.WriteXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataTable
的用法示例。
在下文中一共展示了System.Data.DataTable.WriteXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: exportTblScripts
public static void exportTblScripts(DeviceFile.DeviceScripts[] fScripts, String filename)
{
DTBL tblScripts= new DTBL("Scripts");
setupTblScripts( tblScripts);
System.Data.DataRow myNewRow;
for (int i = 0; i < fScripts.Length; i++)
{
myNewRow = tblScripts.NewRow();
myNewRow["ScriptNumber"] = fScripts[i].ScriptNumber; //UInt16();
myNewRow["ScriptName"] = fScripts[i].ScriptName; //String();
myNewRow["ScriptVersion"] = fScripts[i].ScriptVersion; //UInt16();
myNewRow["UNUSED1"] = fScripts[i].UNUSED1; //UInt32();
myNewRow["ScriptLength"] = fScripts[i].ScriptLength; //UInt16();
myNewRow["Script"] = fScripts[i].Script; //Unit16[];
myNewRow["Comment"] = fScripts[i].Comment; //String();
tblScripts.Rows.Add(myNewRow);
}
tblScripts.WriteXml(filename, System.Data.XmlWriteMode.WriteSchema);
}
示例2: Save
/// <summary>
/// 保存地图文档
/// </summary>
public void Save()
{
//首先确认当前地图文档是否有效
if (m_MapControl.CheckMxFile(m_MapControl.DocumentFilename))
{
////创建一个新的地图文档实例
//IMapDocument mapDoc = new MapDocument();
////打开当前地图文档
//mapDoc.Open(m_MapControl.DocumentFilename, string.Empty);
////判断地图数据是否只读
//if (mapDoc.get_IsReadOnly(m_MapControl.DocumentFilename))
//{
// MessageBox.Show("地图文档只读,不能加载!");
// mapDoc.Close();
// return;
//}
////替换地图目录
//mapDoc.ReplaceContents((IMxdContents)m_MapControl.Map);
////保存地图文档
//mapDoc.Save(mapDoc.UsesRelativePaths,true);
//mapDoc.Close();
System.Data.DataTable dt = new System.Data.DataTable("GIS");
dt.Columns.Add("name");
dt.Columns.Add("value");
dt.Columns.Add("params");
System.Data.DataRow dr = dt.NewRow();
string extent = Math.Round(m_MapControl.Extent.XMax, 2).ToString() + "," + Math.Round(m_MapControl.Extent.XMin, 2).ToString() + "," + Math.Round(m_MapControl.Extent.YMax, 2).ToString() + "," + Math.Round(m_MapControl.Extent.YMin, 2).ToString();
dr = dt.NewRow();
dr[0] = "extent";
dr[1] = extent;
dt.Rows.Add(dr);
string Scale = Math.Round(m_MapControl.MapScale,0).ToString();
dr = dt.NewRow();
dr[0] = "Scale";
dr[1] = Scale;
dt.Rows.Add(dr);
string ckScale = Math.Round(m_MapControl.ReferenceScale,0).ToString();
dr = dt.NewRow();
dr[0] = "ckScale";
dr[1] = ckScale;
dt.Rows.Add(dr);
string Rotation = Math.Round(m_MapControl.Rotation,0).ToString();
dr = dt.NewRow();
dr[0] = "Rotation";
dr[1] = Rotation;
dt.Rows.Add(dr);
for (int i = 0; i < m_MapControl.LayerCount; i++)
{
ILayer player = m_MapControl.get_Layer(i);
if (player is IGroupLayer)
{
dr = dt.NewRow();
dr[0] = "layer";
dr[1] = player.Name;
dr[2] = player.Visible.ToString();
dt.Rows.Add(dr);
setgisxml(ref dt,player as IGroupLayer);
}
else
{
dr = dt.NewRow();
dr[0] = "layer";
dr[1] = player.Name;
dr[2] = player.Visible.ToString();
dt.Rows.Add(dr);
}
}
dt.WriteXml(Application.StartupPath + @"\gis.xml");
}
//else
// this.SaveAs();//新建后m_MapControl.DocumentFilename为空,故调用另存为进行保存
}