To access the currently loaded project from your extension in Visual Studio using VB.NET, you can use the DTE (Development Tools Environment) object provided by the Visual Studio Automation Object Model. The DTE object provides access to the Visual Studio integrated development environment (IDE) and all of its features, including the currently loaded project.
Here is an example of how you can use the DTE object to access the currently active project:
Imports EnvDTE
Dim dte As DTE = CType(GetService(GetType(DTE)), DTE)
Dim activeProject As Project = dte.ActiveSolutionProjects(0)
In the example above, the DTE object is first obtained by calling the GetService method with the DTE type as the argument. Then, the ActiveSolutionProjects property of the DTE object is used to access the currently active project.
Once you have the reference to the project, you can use the ProjectItems property to add a new file to the project and then use Reflection to obtain detailed information about it.
Dim projectItem As ProjectItem = activeProject.ProjectItems.AddFromFile("path/to/your/file.txt")
' Do the Reflection here
' ...
above code snippet is just an example and should be adjusted according to your specific requirements.