//initial serial port private void Init() { try { List <string> list = new List <string>(); string[] ports = USB.GetPorts(); //SerialPort.GetPortNames();// PortcomboBox.Items.Clear(); for (int i = 0; i < ports.Length; i++) { PortcomboBox.Items.Add(ports[i]); } if (ports.Length > 0) { PortcomboBox.SelectedIndex = ports.Length - 1; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public Form1() { InitializeComponent(); usb = new USB(); Init(); }