I am building a internal developer tool. What I would like to be able to do is add a button in my UI that when clicked will open a particular file in Visual Studio for more advanced editing. I would like to use whatever VS window that might already have open.
Is there any way to do this?
To further clarify. Its a custom winform app that edits special XML files. Sometimes the user needs to go over to VS to do more advanced stuff. I would like to just open the file for them instead of them having to browse for it in VS.
You can call the devenv.exe
to run the VisualStudio. if you give a filepath to devenv.exe as argument visual studio opens the given file.
Command : devenv /edit myfile.xml
You can run the above command using Process
class.
Try This:
private void button1_Click(object sender, EventArgs e)
{
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo("devenv.exe", "/edit c:\\Data.txt");
process.StartInfo = startInfo;
process.Start();
}
Note - You need to provide /Edit
argument to open it in same instance. See here: [msdn.microsoft.com/en-us/library/aa991989.aspx][1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With