A program in C # can launch another program using the Process class. The kind of process is part of the System.Diagnostics namespace. You start another program from an instance of a process object, the establishment of the members of which is owned StartInfo, and invoking it start () method. Listing 1 shows how to start a process from C #.
Starting a Process: ProcessStart.cs
using System;
using System.Diagnostics;
namespace csharp_station.howto
{
/// <summary>
/// Demonstrates how to start another program from C#
/// </summary>
class ProcessStart
{
static void Main(string[] args)
{
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";
notePad.Start();
}
}
}
When the program runs in Listing 1 will open the Windows (TM) Notepad application in editing mode in ProcessStart.cs file. The first thing the program is an instance of an object called Process notebook.
Process notePad = new Process();
0 comments:
Post a Comment