Programmatically open a file in Visual Studio (2010)

I am creating a VS package, and I am trying to send a command from the package to Visual Studio to open the file selected by the user in a new tab (just like the user would do this by going to File → Open ...).

At some point, I remember how to do it. Can anyone update my memory?

+7
c # file-io visual-studio-2010
source share
2 answers

I believe you need one of:

In the end, I think they all come down to the same behavior.

+7
source share

I like to use the DTE ExecuteCommand ("commandName") method as you can test the command in the VS command window

In this case, ExecuteCommand ("File.OpenFile")

You can add parameters to the command in the second optional string parameter, if you wish.

+7
source share

All Articles