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

Add interface to newly created folder

$
0
0

Hi,

I am creating an Item Template, have it almost working except for the following problem.

I want to create a folder called "Interfaces" in my project and then add a file called Interfaces.vb to that folder, but I cannot seem to get this working.

Here is a snippet of my simple code.

Private Sub AddInterface(_dte As EnvDTE.DTE)
        Dim _project As EnvDTE.Project = Nothing
        For Each obj As Object In _dte.ActiveSolutionProjects
            _project = TryCast(obj, EnvDTE.Project)
            If _project Is Nothing Then Continue For
        Next

        Dim _folder As EnvDTE.ProjectItem
 	_folder = _project.ProjectItems.AddFolder("Interfaces")
        _folder.ProjectItems.AddFromTemplate("Code\Interface", "IReportSource.vb")
End Sub

I keep getting null reference exceptions, because _folder.ProjectItems is null. So how do I add a file to a folder?

Gary


Viewing all articles
Browse latest Browse all 4410

Trending Articles



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