exception - Programmatically check if a COM port exists in C# -



exception - Programmatically check if a COM port exists in C# -

i got myself using serialport object in c# , realised throws exception saying "com1" not exist. checked device manager see com ports can use, there way find out com ports available , programmatically select 1 of them?

yes, utilize serialport.getportnames(), returns array of strings of available port names.

then create serialport object specifying 1 of names in constructor.

string[] ports = serialport.getportnames(); serialport port = new serialport(ports[0]); // create using first existing serial port, illustration

c# exception serial-port

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -