How to open file programmatically using EnvDTE in C#.
How to open file programmatically using EnvDTE in C#
Asked Answered
Assuming you have a hook to the correct DTE instance...
DTE.ExecuteCommand("File.OpenFile", "c:\\derp.txt");
surround the path with double quotes if it has spaces –
Kiushu
@IvanFerrerVilla's comment fixed (what seemed like an ambiguous) error about "/" is an invalid command that I was getting from VS when running the command because of spaces in the path. –
Caprice
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...
© 2022 - 2024 — McMap. All rights reserved.