Delete file and update Solution Explorer

Hello. I have an 'orphaned file' - one that is not part of the project but only visible within VS Solution explorer if I select 'view all files'.  I have tried numerous ways to delete the file and tried a few methods through dotpeek'ing the resharper code but I can't find a way to refresh the solution view. As it is an 'orpaned file'...it isn't an IProjectItem.  Does the resharper api have a handy way to delete and then notify Visual Studio it needs to refresh the view ?

5 comments
Comment actions Permalink

I'm not sure ReSharper can do this, unfortunately. When deleting files from a project, ReSharper uses the IVSHierarchy interfaces to delete, which causes the solution explorer to refresh automatically. I don't think ReSharper has a way of getting a VS hierarchy item for a file that isn't part of a project. Unfortunately, I think the best you can do is just delete the file - you can use FileSystemPath.DeleteFile for this.

0
Comment actions Permalink

The following ended up working for me (same as clicking refresh):
var dte = Shell.Instance<DTE>.GetComponent();  
dte.Commands.Raise("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}", 222, null, null);

0
Comment actions Permalink

This is part of some logic to delete orphaned project files. I have a QuickFix to handle my highlighting...so I get a 'delete file' action for each highlighting. Is there an easy way to then add an aggregate quickfix ? In my case to offer the user the option to 'delete all' rather than choosing each quick fix individually like RemoveMultipleElementsQuickFix

0
Comment actions Permalink

Yes, ReSharper supports the concept of a Bulk Fix, which is where the alt+enter menu gives the option to fix the current issue, and all issues in the file, project or solution. It's documented here: https://confluence.jetbrains.com/display/NETCOM/4.14+Fix+in+Scope+%28R8%29

0
Comment actions Permalink

Great Thanks - it gave me the pointer to using ExecutableGroupAnchor() and passing that to BulbActionExtensions.ToQuickFixAction  all working nicely now..

0

Please sign in to leave a comment.