How to open Notepad from vb.net and C#

If you want to open text file from vb.net side, suppose you have a simple VB .net program and you want to use a button to open notepad.exe and automatically it have load a specific file you can use this code sample.

[vb.net]

    Private Sub RunNotepad()
        Dim Notepadprocess As New Process()
        Notepadprocess.StartInfo = New ProcessStartInfo("notepad.exe", "E:\New.txt")
        Notepadprocess.Start()
    End Sub

[C#]

Private void RunNotepad()
{
	Process Notepadprocess  = new Process();
	Notepadprocess.StartInfo = new ProcessStartInfo("notepad.exe", "E:\\New.txt");
	Notepadprocess.Start();
}

we use Process.start() method for start notepad.exe, this is the overload method. This method starts the process resource that is specified by the StartInfo property of this Process component and associates it with the component.

Simply a Process component provides access to a process that is running on a computer. A process, in the simplest terms, is a running application. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the code of the process, including parts currently being executed by another thread.

Let’s see another example to open only notepad application through Linklabel control in vb.net. This example requires a windows form with a Linklabel control named ‘LinkLabel1’.

Private Sub Linklabel1_Linkclicked (Byval Sender As System.Object, Byval E As _
      System.Windows.Forms.Linklabellinkclickedeventargs) _
      Handles Linklabel1.Linkclicked
         Linklabel1.Linkvisited = True
          System.Diagnostics.Process.Start("Notepad")
End Sub