Visual Studio Question: How to go to a specific file path and line number programmatically?
In the Visual Studio output window, you can double click a line that contains a file path and line number and it automatically takes you to that loc开发者_开发问答ation. In my program, I need to mimic this behavior and be able to click something (a button for example) and do go to a specific file and line number that I tell it to go to. Any help/suggestions would be appreciated.
I am working in C#.
You can write a macro (Tools/Macros/Macros IDE) to do this. The following commands will select a specific file and go to the given line number.
DTE.Windows.Item("myfile.cs").Activate()
DTE.ExecuteCommand("Edit.Goto", "1234")
精彩评论