private void DeleteFile(DevComponents.AdvTree.Node pNode) { try { string filepath = pNode.Name; if (File.Exists(filepath)) { File.Delete(filepath); pNode.Remove(); } else { if (Directory.Exists(filepath)) { Directory.Delete(filepath, true); pNode.Remove(); } } } catch { } }
/// <summary> /// 删除数据库工程树图节点,同时写入XML /// </summary> /// <param name="xmlDoc"></param> /// <param name="selNode"></param> public static void DelTreeNode(XmlDocument xmlDoc, DevComponents.AdvTree.Node selNode) { XmlNode aNode = xmlDoc.DocumentElement.SelectSingleNode(".//工程[@名称='" + selNode.Text + "']"); if (aNode == null) { return; } xmlDoc.DocumentElement.RemoveChild(aNode); string savepath = xmlDoc.BaseURI; savepath = savepath.Substring(xmlDoc.BaseURI.IndexOf("///") + 3); xmlDoc.Save(savepath); selNode.Remove(); }
private void ClearFromCurNode(DevComponents.AdvTree.Node pNode) { for (int i = pNode.Nodes.Count - 1; i >= 0; i--) { DevComponents.AdvTree.Node pTmpNode = pNode.Nodes[i]; if (pTmpNode.DataKeyString == "DB" && pTmpNode.Text != "现势库") { pTmpNode.Remove(); } else if (pTmpNode.Nodes.Count > 0 && pTmpNode.DataKeyString != "Layer") { ClearFromCurNode(pTmpNode); } } }
private void ProcessDeleteObjMsg(ref Message msg) { int representObjPtr = (int)msg.LParam; object r = m_baseForm.FindTreeNodeByRepresentObjPtr((int)msg.WParam, representObjPtr); TreeNode node = r as TreeNode; DevComponents.AdvTree.Node advNode = r as DevComponents.AdvTree.Node; if (node != null) { node.Parent.Nodes.Remove(node); node.Remove(); } else if (advNode != null) { advNode.Parent.Nodes.Remove(advNode); advNode.Remove(); } LogicHelper.UpdateNodesCountDesc(); }