'C# Process.kill doesnt have the function only Process.start

There is only the function to Process start

Example:

Process.Start("https://discord.gg/example");

And I want to add another option on a bool to close the

Process.Kill("https://discord.gg/example");

(Process does not know the definition for Kill) also not for Process.kill or Process.Close

Is there a other way to Do this?



Solution 1:[1]

Check the oficial documentation so you can assign the process to an object, after starting that process within the object, you can "killl it" whenever you want.

Example:

    Process myProcess;
    private void startNotepad(object sender, EventArgs e)
    {
        try
        {
            myProcess = new Process();
            myProcess.StartInfo.FileName = "notepad";
            myProcess.Start();
        }
        catch (Exception E)
        {
            Console.WriteLine(E.Message);
        }
    }

    private void killNotepad(object sender, EventArgs e)
    {
        myProcess.Kill();
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1