Пример #1
0
        /// <summary>
        /// 加载专案目录
        /// </summary>
        /// <param name="path"></param>
        /// <param name="node"></param>
        /// <param name="nodeDic"></param>
        private void LoadDir(string path, TreeNode node, Dictionary <string, TreeNode> nodeDic)
        {
            string[] dir = DirFileHelper.GetDirectories(path);
            int      k   = path.Length + 1;

            if (dir != null)
            {
                for (int i = 0; i < dir.Length; i++)
                {
                    TreeNode sNode = new TreeNode(dir[i].Substring(k), 1, 1);
                    sNode.Tag = dir[i];
                    node.Nodes.Add(sNode);
                    nodeDic[dir[i]] = sNode;
                    LoadDir(dir[i], sNode, nodeDic);
                }
            }
            LoadFile(path, node, nodeDic);
            node.Expand();
        }
Пример #2
0
        private StringBuilder ExecDosCommand(StringBuilder sb, string rootPath, string destPath)
        {
            List <string> lstCMD = new List <string>();
            Random        random = new Random();

            sb.Append($"wwwrootDir:{rootPath}\r\n");
            sb.Append($"copyDir:{destPath}\r\n");
            string[] saDir = DirFileHelper.GetDirectories(rootPath);
            sb.Append($"saDir:{saDir.ToJson()}");
            for (int i = 0; i < saDir.Length; i++)
            {
                string[] saDirPath = saDir[i].Split("\\");
                string   dirName   = saDirPath[saDirPath.Length - 1];
                //sb.Append($"dirName:{dirName}");
                if (dirName.Equals("NcfDocs"))
                {
                    lstCMD.Add($"cd wwwroot");
                    sb.Append($"dirName----{dirName}         ");
                    string strNewName = $"NcfDocs-Old{DateTime.Now.ToString("yyyyMMddHHmmss")}{random.Next(1000, 9999).ToString()}";
                    lstCMD.Add($"REN NcfDocs {strNewName}");
                    continue;
                }
                else if (dirName.Contains("NcfDocs-Old"))
                {
                    lstCMD.Add($"RD /S /Q {dirName}");
                    continue;
                }
                else
                {
                    continue;
                }
                //lstCMD.Add($"RD /S /Q {destPath}");
            }
            string strExecRes = CmdHelper.ExeCommand(lstCMD.ToArray());

            sb.Append(strExecRes);
            return(sb);
        }