private void AutoImportCOMDll_Click(object sender, EventArgs e) { TreeNode firstNode = _selectedTree?.SelectedNode; if (firstNode == null) { return; } TreeViewEx sourceRegTree = ((ToolStripItem)sender)?.Tag as TreeViewEx; var comDll = GetComDLLFiles(sourceRegTree); comDll.Sort(); int startIndex = 1; firstNode.Nodes.Clear(); foreach (var item in comDll) { if (!string.IsNullOrWhiteSpace(item)) { var fileInfo = new Model.FileInfo(item); var newNode = firstNode.Nodes.Add(string.Format("{0}={1}", startIndex, fileInfo.RelativePath)); startIndex++; newNode.Tag = fileInfo; } } }
private void UpdateExeListInternal(TreeNode appNode, List <string> appList, List <string> exeFileNameList, List <string> appPathList, List <string> otherList, List <string> dllOcxList) { if (appNode == null) { return; } Model.FileInfo fileInfo = appNode.Tag as Model.FileInfo; if (fileInfo != null) { string fileExt = Path.GetExtension(fileInfo.AbsolutePath).ToLower(); if (fileExt == ".exe" || fileExt == ".bat" || fileExt == ".com") { appList.Add(appNode.GetFullPath("App")); exeFileNameList.Add(appNode.Text); appPathList.Add(appNode.GetDirectory().Trim('\\')); } else if (fileExt == ".dll" || fileExt == ".ocx") { dllOcxList.Add(appNode.GetFullPath("App")); } else if (appNode.IsDescendantOf("DefaultData")) { if (fileExt == ".reg" || fileExt == ".ini" || fileExt == ".xml") { string fullPath = string.Format("%PAL:DataDir%\\{0}", appNode.GetFullPath("DefaultData")); otherList.Add(fullPath); } } else if (appNode.IsDescendantOf("Data")) { if (fileExt == ".reg" || fileExt == ".ini" || fileExt == ".xml") { string fullPath = string.Format("%PAL:DataDir%\\{0}", appNode.GetFullPath("Data")); otherList.Add(fullPath); } } } foreach (TreeNode item in appNode.Nodes) { UpdateExeListInternal(item, appList, exeFileNameList, appPathList, otherList, dllOcxList); } }