using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Demo_Thread{
public class StartProcessExample{
static void Main(string[] args){
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "notepad++.exe"; startInfo.Arguments = "noominhee.txt"; startInfo.WorkingDirectory = @"G:\LTW3\2";
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.ErrorDialog = true;
using (Process process = new Process()) {
process.StartInfo = startInfo;
try{
process.Start();
Console.WriteLine("Waiting 30 seconds for process to" + " finish.");
process.WaitForExit(30000);
}
catch (Exception ex) {
Console.WriteLine("Could not start process.");
Console.WriteLine(ex);
}
}
Console.WriteLine("Main method commplete. Press Enter.");
Console.ReadLine();
}
}
}
No comments:
Post a Comment