using System;
using System.Windows.Forms;

namespace GetSerialPorts{

public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void btnGetPortNames_Click(object sender, EventArgs e)
{
lbSerialPortNames.Items.Clear();
foreach (string item in System.IO.Ports.SerialPort.GetPortNames())
{
//store the each retrieved available prot names into the Listbox...
lbSerialPortNames.Items.Add(item);
}
}
}
}

Using the System.IO.Ports.SerialPort.GetPortNames() it will retrieve the all available serial port names.

See Below Images To Get More Clear View :

01.png


02.png