Ajit More

Ajit More

  • NA
  • 569
  • 334.7k

How to kill process ?

Nov 17 2016 7:53 AM
Hi friends,
 
i want to close process and run every time using for loop ?
 
But Process run only first time and after that show error process stop , not start next process automatically
 
DirectoryInfo d = new DirectoryInfo(txtfolderpath.Text);
Files = d.GetFiles("*.kmz").Union(d.GetFiles("*.kml")).ToArray(); //Getting kml,kmz files
str1 = new string[Files.Length];
for (int i = 0; i < Files.Length; i++)
{
str1[i] = Files[i].Name;
// Create new stopwatch.
Stopwatch stopwatch = new Stopwatch();
// Begin timing.
stopwatch.Start();
// Start Google Earth
Process process = Process.Start(txtfolderpath.Text + "\\" + str1[i]);
int timese = Convert.ToInt16(Convert.ToInt16(txttime.Text) * 1000);
// Wait process
Thread.Sleep(timese);
// Stop timing.
stopwatch.Stop();
// Stop Google Earth
process.Kill();
}
 
 
 

Answers (1)