You can use the System.IO.Ports.SerialPort.GetPortNames method to retrieve a string array of all available COM ports on the current system. Here's an example code:
main.cs177 chars11 lines
This code will output a list of all available COM ports in the console. Note that you need to include the System.IO.Ports namespace for this to work.
gistlibby LogSnag