I have a code which displays the list of ports where a connection is made. For example, if I have two USB points in the laptop and only one is being used with a USB Cable attached, it should show only the one where the USB Cable is attached. This code used to work perfectly till sometime back, but now it is showing all the ports.
What could be the solution?
Below is my code.
try
{
string[] ports = SerialPort.GetPortNames();
comboBox1.Items.AddRange(ports);
comboBox1.SelectedIndex = 0;
button2.Enabled = false;
}
catch
{
MessageBox.Show("Error.", "No Port detected.", MessageBoxButtons.OK, MessageBoxIcon.Error);
comboBox1.Text = "";
}