To list all available COM ports in C#, you can use the SerialPort static method GetPortNames()
. Here's an example:
main.cs140 chars10 lines
This code will output the name of each available COM port to the console. Note that you'll need to add a reference to the System.IO.Ports
namespace at the top of your code file to use the SerialPort
class.
gistlibby LogSnag