Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

ProjectNode.RemoveChild does not remove item from solution explorer.

$
0
0
Hi,

During the build process for my custom project type, a number of files are created that I want to appear as files in in a sub tree of my project in Solution Explorer. I have managed to to do this, but when the project is Cleaned I need to remove the files from the tree.


My code in my ProjectNode does this to create the items:

...
FolderNode foldernode = this.CreateFolderNode(dir);
parentnode.AddChild(foldernode);
...
FileNode filenode = this.CreateFileNode(file);
foldernode.AddChild(fnode);
...

and then to remove the items:

        private void RemoveItemTree(FolderNode dirnode, HierarchyNode parentnode)
        {
            List<FolderNode> folders = new List<FolderNode>();
            dirnode.FindNodesOfType<FolderNode>(folders);
            foreach (FolderNode fnode in folders)RemoveItemTree(fnode, dirnode);

            List<FileNode> files = new List<FileNode>();
            dirnode.FindNodesOfType<FileNode>(files);
            foreach (FileNode fnode in files)dirnode.RemoveChild(fnode);

            parentnode.RemoveChild(dirnode);
        }

However, in SolutionExplorer, the tree of folders and files is still visible, although they no longer respond to right clicks for their context menus.

What am I doing wrong here?

Thanks,

Simon.


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>