-
Notifications
You must be signed in to change notification settings - Fork 202
Getting a List of Serial Ports with SerialPortStream
MrEngineer02 edited this page May 2, 2017
·
3 revisions
SerialPortStream uses two mechanisms to obtain details about serial ports: the registry; and the Windows Management Interface (WMI). There is one method compatible with System.IO.SerialPort, the other is new.
This method is compatible with the Microsoft implementation:
using System.Diagnostic;
foreach (string c in SerialPortStream.GetPortNames()) {
Trace.WriteLine("GetPortNames: " + c);
}
To get a description about the serial port also:
using System.Diagnostic;
foreach (SerialPortStream.PortDescription desc in SerialPortStream.GetPortDescriptions()) {
Trace.WriteLine("GetPortDescriptions: " + desc.Port + "; Description: " + desc.Description);
}