Execute another Process or Open a File using its Application is very simple in C#.
There is Separate Name space "System.Diagnostics" is available
There is class named as Process will execute all kind process.
If you want to execute a Exe or open File then a single line can do this
i.e
Process.Start(filepath);
Ex1:
Process.Start("c:\\windows\\notepad.exe");
This statement will open a NotePad Application
Ex2:
Process.Start("c:\\a.doc");
It will Open a.doc File in Word Application.This is applicable to All kind Executable Files.
If you want to give some command line Arguments means use
Process p = new Process();
p.StartInfo.FileName = "c:\\windows\\notepad.exe"; //exe path
p.StartInfo.Arguments = "c:\\a.txt"; //filepath
p.Start();
And also we have more No of options in Process class.
Start Time,End Time,Priority,Memory size,Availability etc.you can start,stop a Process.
If you want to run a process in background
then use following statement.
p.StartInfo.CreateNoWindow = true;
Thank you.
No comments:
Post a Comment