0

I'm curious if there is a way for a .cs file to programmatically open and navigate to a c# line of code (similar to ctrl + g) via

public static System.Diagnostics.Process Start (string fileName, **string arguments**);

Is it possible to use the overload string arguments to accomplish this?

I am currently using the single argument Process.Start() to open the .cs file and am copying the line# to clipboard, but the user still need to press ctrl+g && ctrl+v which is what I am trying to eliminate.

Clipboard.SetText(dr["Line"].ToString());
System.Diagnostics.Process.Start(Path.Combine(dr["Folder"].ToString(), dr["Filename"].ToString()));
  • You cannot run a `.cs` file. A `.cs` file is just source code, not executable instructions. You will first need to compile it which turns your source code to executable instructions and then the .NET runtime must execute it as it knows how to execute those instructions. – Mushroomator Dec 07 '22 at 00:11
  • Well it might be tricky with `Process.Start` but you can use automation technologies such as _Microsoft UI Automation_ to programmatically _run an application; tell it to open a file; and copy content to the clipboard_, yes. –  Dec 07 '22 at 00:26
  • https://stackoverflow.com/questions/350323/open-a-file-in-visual-studio-at-a-specific-line-number – aybe Dec 07 '22 at 03:13

0 Answers0