-1
using System;
using System.IO.Ports;
public static void getPorts()
{
string[] ports = SerialPort.GetPortNames();
Console.WriteLine("The following serial ports were found:");
foreach (string port in ports)
{
Console.WriteLine(port);
}
Console.ReadLine();
}
我對這個簡單的代碼有問題。我需要寫出我的端口,因爲我稍後會與他們合作(我在我的大型應用程序中使用了這個簡單的功能)。一切工作,直到我升級我的Windows。你有什麼想法可能是什麼問題?我也安裝了所有的驅動程序。SerialPort(.net) - 沒有找到端口
確切的問題是什麼?你有什麼錯誤嗎?請在代碼中添加'try-catch'塊。 –
我是否正確,我認爲你的港口已經消失了? –
你能看到設備管理器中的端口號 – JSR