导入
/// <summary>
/// 导入XML
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnInputXML_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog myopenfiledialog = new OpenFileDialog();
myopenfiledialog.Filter = "流程文件|*.xml";
if (myopenfiledialog.ShowDialog().Value)
{
Stream stream = myopenfiledialog.File.OpenRead();
StreamReader streamreader = new StreamReader(stream, System.Text.Encoding.UTF8);
//inputxml(string xml)将字符串进行处理还原对象
inputxml(streamreader.ReadToEnd());
stream.Close();
}
}
导出
/// <summary>
/// 导出XML
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOutXML_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog mysavefiledialog = new SaveFileDialog();
mysavefiledialog.Filter = "流程文件|*.xml";
mysavefiledialog.DefaultExt = ".xml";
if (mysavefiledialog.ShowDialog().Value)
{
using (Stream fs = (Stream)mysavefiledialog.OpenFile())
{
//outxml()将对象生成字符串
byte[] info = (new System.Text.UTF8Encoding(true)).GetBytes(outxml());
fs.Write(info, 0, info.Length);
fs.Close();
}
}
}