Original Post
I would like to find out a clever way of finding which ports are available. I have finally figured out that my microcontroller is connected to COM 5, or at least is being registered at COM 5 when I use my hyperterminal program I wrote in C#. However, I'm looking more toward a way to see which ports are available for open prior to opening them. I tried SerialPort SP = new SerialPort("COM1"); if(SP.IsOpen) //do stuff else SP = new SerialPort("COM2") if(SP.IsOpen) // do stuff here else etc... However, that can't technically be used until you have successfully opened the port, which means as you open the port SP.Open(); you're going to get an error while you're debugging it, and it's going to stop your program, since COM1 - COM4 doesn't exist. Which means I literally had to do the following on page load over and over until I found that yes I can connect to the program through the microcontroller, but it's trial and error, and I don't like it. SP = new SerialPort("COM1"); test program change to SP = new SerialPort("COM2"); test program change it to do this process until we have successfully come to SP = new SerialPort("COM5"); Sp.Open(); if(SP.IsOpen) MessageBox.Show("Connected successfully!); of course when I actually want to run the program, and use it on another system I'm going to need an algorithm to find which ports are open. My previous methods have not work, so I'm asking a community for some help. Thank you,