C# Get Available Serial Port Names – Programming, Pseudocode Example, C# Programming Example
C# Console General

C# Get Available Serial Port Names

PortName property of the SerialPort class will list all serial port that is connectted the pc.


if you want to connect directly any port , you can chance portName variable and get connection.

In following example:

I entered com3 and connected it



string[] ports = SerialPort.GetPortNames();
foreach (string portName in ports)
Console.WriteLine(portName);//read available port names
var port = new SerialPort(portName, 256000);
catch (Exception ex)

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.