I want to make a program that detects if a certain device is connected to a COM port by the device name when a button is clicked. For example, if the device is connected and it shows "HUAWEI Mobile Connect - 3G PC UI Interface (COM16)" in the device manager, say in a message box if the device is connected.
I have a code but it only shows the available COM port.
private void button1_Click(object sender, EventArgs e)
{
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
richTextBox1.Text = port.ToString();
}
}
