Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
the truth is that I do not know how to start when we do right click and go to Device Manager shows us in the ports a list of connected devices, now I want to know how I can bring that same list to my combobox, working in windowsForm C #:



this is imagen Port Imagen

What I have tried:

this is imagen Port Imagen
Posted
Updated 17-Oct-17 2:58am

 
Share this answer
 
This is solution

using System;
using System.IO.Ports;

namespace SerialPortExample
{
    class SerialPortExample
    {
        public static void Main()
        {
            string[] ports = SerialPort.GetPortNames();

            foreach(string port in ports)
            {
                Console.WriteLine(port);
            }

            Console.ReadLine();
        }
    }
}
 
Share this answer
 
In c#, you can get PC details using

System.Environment.PortNumber

you may also get other details like MachineName etc.
 
Share this answer
 
Comments
Rodrigo Alex Rodriguez 17-Oct-17 9:57am    
how use ?
Richard MacCutchan 17-Oct-17 11:22am    
Exactly where is PortNumber in Environment Class (System)[^]?
Rodrigo Alex Rodriguez 18-Oct-17 9:30am    
i do not understand the method

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900