/// <summary> /// open file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Open_Click(object sender, EventArgs e) { TreeListNode fileNode = treeFile.FocusedNode; if (fileNode == null) { MessageBox.Show("Error, no file selected!"); return; } else { try { string path = fileNode.Tag.ToString(); XmlSerializer serializer = new XmlSerializer(typeof(TSchem)); FileStream fs1 = new FileStream(path, FileMode.Open); XmlReader reader = XmlReader.Create(fs1); CurrentTSchem = (TSchem)serializer.Deserialize(reader); fs1.Close(); //show information included in xml file setAllPage(); } catch (InvalidOperationException) { MessageBox.Show("File format error", "Error!"); } return; } }
public void LoadXml(string path, ref TSchem schem) { XmlSerializer serializer = new XmlSerializer(typeof(TSchem)); FileStream fs1 = new FileStream(path, FileMode.Open); XmlReader reader = XmlReader.Create(fs1); schem = (TSchem)serializer.Deserialize(reader); fs1.Close(); }
public Frmsceme() { CurrentTSchem = new TSchem(); SaveMode = false; frw = new TFileRW.TFileRW(); XmlFunc = new TXmlFunction.TXmlFunction(); //Instance //ISchemeManage FSchemeManage; //CreateNewDllInstance gll = new CreateNewDllInstance(Application.StartupPath + @"\\PrjInstance"); //FSchemeManage = gll.CreateByContainer<ISchemeManage>("TSchemeManage"); InitializeComponent(); schemeTopPath = Application.StartupPath + @"\category"; }
public void SaveXml(string path, TSchem schem) { XmlSerializer xs = new XmlSerializer(schem.GetType()); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.GetEncoding("gb2312"); settings.Indent = true; XmlWriter writer = XmlWriter.Create(path, settings); ns.Add("", ""); xs.Serialize(writer, schem, ns); writer.Close(); }
public void SaveFile(TSchem schem, string path) { try { XmlSerializer xs = new XmlSerializer(schem.GetType()); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.GetEncoding("gb2312"); settings.Indent = true; XmlWriter writer = XmlWriter.Create(path, settings); ns.Add("", ""); xs.Serialize(writer, schem, ns); writer.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } }