I'm trying to build an extension for Visual Studio 2017, the idea is to automatically include files that are created in a certain folder on disk (using a FileSystemWatcher), any changes to folder names and/or filenames should also be reflected (included) i the Project.
I've looked around for an existing extension without any luck.
After working on this for a while I'm quite close to a solution but the current approach that I have for removing items from the Solution Explorer when file/foldernames are changed/deleted does not scale when the solution is bigger (have many files in it). My current approach is to use the root IVsHierarchy and process it recursively and then find a file/folder based on the "canonicalName". This means that I have to scan the solution each time i need to find a folder. The solution is inspired by this code https://www.mztools.com/articles/2014/MZ2014007.aspx
I started out with using Project.ProjectItems but this collection would sometimes just contain a "root" folder ie with these files on disk
/Test/MyFile.txt
/Test/Folder1
/Test/Folder2
/Test/Folder3
The only ProjectItem that I could find was /Test/, this does not work if I need to remove /Test/Folder1 ie. The approach with IVsHierarchy gave me all the folder and the implementation works but are slow.
So, my question:
Is there a way to get a reference to a ProjectItem based on the full path of the file/folder on disk? So that I don't have to iterate over all items in the solution to find my ProjectItem and slow down everything. It would also work with a reference to a IVsHierarchy that I can use to get the ProjectItem.
Any help would be very much appreciated.
Cheers!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.