Reputation: 3680
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.
Upvotes: 6
Views: 4365
Reputation: 26209
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]
Upvotes: 10