-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