2016-05-30 194 views
1

我最近正在進行串行端口通信的項目,我想在comboBox中顯示可用的串行端口,但運行時並未顯示com端口的可用列表。Visual Studio中沒有顯示可用的串行端口

我的代碼:

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using System.IO.Ports; 

namespace Serial_application 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
      getPortsNames(); 
     } 
     void getPortsNames() 
     { 
      string[] ports = SerialPort.GetPortNames(); 
      comboBox1.Items.AddRange(ports); 
     } 
    } 
} 
+1

你檢查了你的可用端口嗎? –

+0

您在訪問端口或顯示端口時遇到問題嗎? 你在視覺工作室之外檢查過嗎?像通過COM端口連接的設備在設備管理器中顯示一樣嗎?你可以通過其他方式訪問它們嗎? – Zero

+0

首先檢查設備管理器中的可用端口。 –

回答

0

上有最先進的計算機沒有舊式COM端口,它們是USB轉換器。如果USB設備驅動程序尚未安裝,則計算機中未列出任何端口。我自己解決了這個問題。

相關問題