Get all installed Serial Port using C#
Today we will learn about Serial Port, how to get all installed Serial Port using C#.
We would be required “System.IO.Ports” namespace . We get all list of Serial ports using SerialPort.GetPortName() method as list of string array.
Below is the code snippet to get all installed Serial ports in your local computer using c#:
using System; namespace GetAllInstalledSerialPorts { class Program { static void Main(string[] args) { Console.WriteLine("Get all installed Serial Ports in your computer."); foreach (string item in System.IO.Ports.SerialPort.GetPortNames()) Console.WriteLine(item); Console.ReadKey(); } } }