Diwesh Saxena

Diwesh Saxena

  • 0
  • 1
  • 2.4k

Finding the serial device COM port

Aug 17 2014 10:05 PM

I have a Windows C# application . The application connects to a RFID card reader over serial port . Though i have given it COM port 3 by default . I land into situations where user's port is not available and his port being used is something different by his windows OS.

My application does give user the ability to change the COM port , but to find which COM port is being used by their operating system , user needs to go to Device Manager and check , which a novice person might not be comfortable with .

Is there a function or a way to find exactly to what port is my RFID card connected to in Windows , so that i can simply display like :

Application Port Set to : COM .... Device Connection Port on OS : COM ....

Also my target framework is 3.5

Edit 1:

Tried using SerialPort.GetPortNames() but it returns an empty string as : System.String[]..

My RFID device is listed under Device Manager ===> Ports(COM & LPT) as Silicon Labs CP210x USB to UART Bridge (COM3)

Answers (1)