using EnvDTE; using Microsoft.VisualStudio.Shell.Interop; public void DeleteItem(Project project) { string itemName = "myfile.txt"; ProjectItem item = project.ProjectItems.Item(itemName); item.Delete(); }
using EnvDTE; using Microsoft.VisualStudio.Shell.Interop; public void DeleteFolder(Project project) { string folderName = "myfolder"; ProjectItem item = project.ProjectItems.Item(folderName); item.Delete(); }In both examples, the ProjectItem Delete method is used to delete the item from the project. These examples require the use of the Microsoft.VisualStudio.Shell.Interop package library.