Skip to content

How to kill process ?

Ajit More

Ajit More

Asked Nov 17, 2016, 2:53 AM EST1 answer
Share
LinkedInX
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
 
Java
 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();

                }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Process.GetCurrentProcess().Kill();
     
    try this 
    0