在C#编码中了解com端口 [英] knowing com port in c# coding
本文介绍了在C#编码中了解com端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该如何在c#中编写代码以查找com端口((并自动将其更改为com1))
how can i write a code in c# for finding com port ((and automatically change it to com1))
推荐答案
为什么不尝试过与谷歌? Google是您的朋友,请始终尝试使用它.
尝试使用 SerialPort.GetPortNames方法 [ [C#]如何通过友好名称以编程方式找到COM端口 [ SerialPort(RS-232 C#.NET中的串行COM端口) [ http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/a2294b6a-3f5f-43ab-90b4-5cb516524ed4 [ http://stackoverflow.com/questions/1081871/how-to-find-available- com-ports [ ^ ]
--Amit
Why you don''t tried this with google? Google is your friend, always try using that.
Try using SerialPort.GetPortNames Method [^].
Refer the links below for similar articles:
[C#] How to programmatically find a COM port by friendly name[^]
SerialPort (RS-232 Serial COM Port) in C# .NET[^]
View similar threads:
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/a2294b6a-3f5f-43ab-90b4-5cb516524ed4[^]
http://stackoverflow.com/questions/1081871/how-to-find-available-com-ports[^]
--Amit
hiii,
hiii,
using System;
using System.IO.Ports;
namespace SerialPortExample
{
class SerialPortExample
{
public static void Main()
{
// Get a list of serial port names.
string[] ports = SerialPort.GetPortNames();
Console.WriteLine("The following serial ports were found:");
// Display each port name to the console.
foreach(string port in ports)
{
Console.WriteLine(port);
}
Console.ReadLine();
}
}
}
http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.getportnames.aspx [ http://stackoverflow.com/questions/1081871/how-to-find-available- com-ports [ ^ ]
http://dariosantarelli .wordpress.com/2010/10/18/c-how-to-programmatically-find-a-com-port-by-friendly-name/ [
http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.getportnames.aspx[^]
http://stackoverflow.com/questions/1081871/how-to-find-available-com-ports[^]
http://dariosantarelli.wordpress.com/2010/10/18/c-how-to-programmatically-find-a-com-port-by-friendly-name/[^]
这篇关于在C#编码中了解com端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文