Esempio n. 1
0
        public void Delete()
        {
            string strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + m_strStepName;

            if (Directory.Exists(strPath))
            {
                FileOpert.DeleteFolder(strPath);
            }
        }
Esempio n. 2
0
        //public static void DeleteFolder(string dirPath)
        //{
        //    if (Directory.Exists(dirPath))
        //    {
        //        foreach (string content in Directory.GetFileSystemEntries(dirPath))
        //        {
        //            if (Directory.Exists(content))
        //            { Directory.Delete(content, true); }
        //            else if (File.Exists(content))
        //            { File.Delete(content); }
        //        }
        //    }
        //}

        private void BtnDel_Click(object sender, EventArgs e)
        {
            if (treeView_ProdutFile.SelectedNode == null)
            {
                MessageBox.Show("请选择要添加子节点的节点!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (treeView_ProdutFile.SelectedNode == treeView_ProdutFile.Nodes[0])
            {
                MessageBox.Show("不能删除根结点!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (ParamSetMgr.GetInstance().CurrentWorkDir == "")
            {
                MessageBox.Show("当前产品目录文件夹!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            bool bFind = Directory.Exists(ParamSetMgr.GetInstance().CurrentWorkDir);

            if (!bFind)
            {
                MessageBox.Show("当前产品目录文件夹!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (treeView_ProdutFile.SelectedNode == treeView_ProdutFile.Nodes[0].Nodes[0])
            {
                MessageBox.Show("当前产品文件不能删除,请先载入!", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string strdirPath = ParamSetMgr.GetInstance().CurrentWorkDir + ("\\") + treeView_ProdutFile.SelectedNode.Text;

            if (MessageBox.Show($"是否确定删除{treeView_ProdutFile.SelectedNode.Text}", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
            {
                return;
            }
            if (Directory.Exists(strdirPath))
            {
                // DeleteFolder(strdirPath);
                FileOpert.DeleteFolder(strdirPath);
            }
            treeView_ProdutFile.SelectedNode.Remove();
        }