| Author: |
Carlos J. Quintero (Microsoft MVP) |
Applies to: |
Microsoft Visual Studio .NET 2002 |
| Date: |
May 2011 |
|
Microsoft Visual Studio .NET 2003 |
| |
|
|
Microsoft Visual Studio 2005 |
| |
|
|
Microsoft Visual Studio 2008 |
| |
|
|
Microsoft Visual Studio 2010 |
Introduction
The automation model (EnvDTE) of Visual Studio provides the EnvDTE.Project.Delete
method to delete a project of a solution. However, when that method is called,
you get a System.NotImplementedException. As a workaround, you can use the
EnvDTE.Solution.Remove method to remove the project from the solution and then
delete the folder of the project using the System.IO.Directory.Delete method.
More Information
The following macro shows the code to delete the first project a solution that
reproduces the problem and the workaround:
| Language: VB.NET | Copy Code (IE only) |
Sub DeleteProject()
Dim folder As String
Dim prj As Project
Try
prj = DTE.Solution.Projects.Item(1)
' This causes System.NotImplementedException
' prj.Delete()
folder = System.IO.Path.GetDirectoryName(prj.FullName)
DTE.Solution.Remove(prj)
System.IO.Directory.Delete(folder, True)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this
|