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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -