c# - Open Notepad++ with arguments

PHOTO EMBED

Mon Mar 14 2022 20:04:49 GMT+0000 (Coordinated Universal Time)

Saved by @javicinhio #cs

private void openLog() {
            try {
                // see if notepad++ is installed on user's machine
                var nppDir = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Notepad++", null, null);
                if (nppDir != null) {
                    var nppExePath = Path.Combine(nppDir, "Notepad++.exe");
                    var nppReadmePath = Path.Combine(yourDirectory,fileName );
                    var line = 20;
                    var sb = new StringBuilder();
                    sb.AppendFormat("\"{0}\" -n{1}", nppReadmePath, lineNo);
                    Process.Start(nppExePath, sb.ToString());
                } else {
                    string newPath = @"\\mySharedDrive\notpad++\bin\notepad++.exe";
                    Process.Start(newPath, @"\\" + filePath + " -n" + lineNo); // take exe from my shared drive
                }
            } catch (Exception e) {
                Process.Start(@"\\" + FilePath); // open using notepad
            }
        }
content_copyCOPY

https://stackoverflow.com/questions/13755233/how-to-launch-a-process-which-will-open-a-text-file-in-any-editor-and-automatica