Does C# provide an effective means of scanning the available COM ports? I would like to have a dropdown list in my application wherein the user can select one of the detected COM ports. Creating and populating the dropdown list is not a problem. I just need to know how to scan for the available COM ports using C#.
C# – How to scan for COM ports in C#
cserial-port
Related Topic
- C# – How would you do a “not in” query with LINQ
- C# – What are the correct version numbers for C#
- C# – How to save application settings in a Windows Forms application
- C# – How to build a query string for a URL in C#
- Python – Listing serial (COM) ports on Windows
- C# – How to generate a random int number
- Scala: list.flatten: no implicit argument matching parameter type (Any) = > Iterable[Any] was found
Best Answer
System.IO.Ports is the namespace you want.
SerialPort.GetPortNames will list all serial COM ports.
Unfortunately, parallel ports are not supported directly from C#, as they're very infrequently used except in legacy situations. That said, you can list them by querying the following registry key:
See the Microsoft.Win32 namespace for details.