6

How to open file programmatically using EnvDTE in C#.

Philip Pittle
  • 11,821
  • 8
  • 59
  • 123
user591790
  • 545
  • 2
  • 15
  • 33

2 Answers2

11

Assuming you have a hook to the correct DTE instance...

DTE.ExecuteCommand("File.OpenFile", "c:\\derp.txt");
1

You can try the following snippet directly in the Visual Studio Console:

$DTE.ItemOperations.OpenFile("c:\derp.txt",$DTE.Constants.vsViewKindTextView)

It should open the file as long as it exists...

Emil
  • 2,196
  • 2
  • 25
  • 24