How to open Notepad from and C#

If you want to open text file from 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.


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


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

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 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
End Sub