How to

enumerate serial ports

Published: 8. January 2009 | Updated: 26. October 2011
License: Microsoft Public License (MS-PL)
Categories: Windows » Hardware, Network
Tags: C# Hardware Network Windows
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at analyzant.com

Import namespace

using System.IO.Ports;

Code

foreach (string portname in SerialPort.GetPortNames())
{
    Console.WriteLine(portname);
}
Console Output:
COM1
COM2
Send us feedback about this snippet »



Related Snippets: