Ejemplo n.º 1
0
 public void SaveTreeViewData(TreeView tv, string path)
 {
     if (path.ToLower().EndsWith(".xml") || path.ToLower().EndsWith(".mdzip"))
     {
         XMLOperate xmlop = new XMLOperate();
         xmlop.SeavTreeViewToXml(tv.Nodes, path, "MD");
     }
     else
     {
         BinaryFormatter formatter           = new BinaryFormatter();
         Stream          serializationStream = new FileStream(path, FileMode.Create);
         formatter.Serialize(serializationStream, new TVD(tv));
         serializationStream.Close();
     }
 }
Ejemplo n.º 2
0
 public void LoadTreeViewData(TreeView treeView, string path)
 {
     if (path.ToLower().EndsWith(".xml") || path.ToLower().EndsWith(".mdzip"))
     {
         XMLOperate xmlop = new XMLOperate();
         xmlop.LoadXmlToTreeView(treeView, path);
     }
     else
     {
         BinaryFormatter formatter = new BinaryFormatter();
         formatter.Binder = new UBinder();
         Stream serializationStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
         ((TVD)formatter.Deserialize(serializationStream)).PopulateTree(treeView);
         serializationStream.Close();
     }
 }
Ejemplo n.º 3
0
 public Hashtable LoadTreeViewData(TreeNode tn, string path)
 {
     if (path.ToLower().EndsWith(".xml") || path.ToLower().EndsWith(".mdzip"))
     {
         XMLOperate xmlop = new XMLOperate();
         return(xmlop.LoadXmlToTreeNode(tn, path));
     }
     else
     {
         BinaryFormatter formatter = new BinaryFormatter();
         //如果没有这一句,无法实现不同版本的反序列化
         formatter.Binder = new UBinder();
         Stream serializationStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
         ((TVD)formatter.Deserialize(serializationStream)).PopulateTree(tn);
         serializationStream.Close();
         return(null);
     }
 }
Ejemplo n.º 4
0
 public void loadXmlByPath(string path)
 {
     this.xml         = new XMLOperate(path);
     this.xmlSavePath = path;
     this.aountRunTime();
 }