You can find out what ports are (probably) availble with
SerialPort.GetNames[
^] - but...this queries the registry, so it may be inaccurate in that it can return ports that aren't there any more.
And there is no "automatic" system fort detecting "available" ports - if a port is in use by another program it will not be "available" but AFAIK the only way to check is to try opening it and catching the exception.