C#: Retrieving and Sorting COM Ports
By admin on Jun 29, 2009 in .NET, Programming
In .NET, it is easy to retrieve all existing COM ports and sort them accordingly
string[] portNames = SerialPort.GetPortNames();
var sortedList = portNames.OrderBy(port => Convert.ToInt32(port.Replace("COM", string.Empty)));
foreach (string port in sortedList)
{
Console.WriteLine(port);
}
Sorry, comments for this entry are closed at this time.