string getPullOutSerialPort(string[] portNames, string[] portNameNew)
{
int i = 0;
//string[] portNameNew = SerialPort.GetPortNames();
//if (portNames.Equals(portNameNew))
if (portNameNew.Length >= portNames.Length)
{
return null;
}
Array.Sort(portNames);
Array.Sort(portNameNew); //多出的COMx
//foreach (string port in portNames)
for (i = 0; i < portNames.Length; i++)
{
for (int j = 0; j < portNameNew.Length; j++)
{
if (portNameNew[j] == portNames[i])
{
goto GetNext;// break;
}
}
return portNames[i];
GetNext:
continue;
}
return null;
}
string getInsertSerialPort(string[] portNames, string[] portNameNew)
{
int i = 0;
//string[] portNameNew = SerialPort.GetPortNames();
//if (portNames.Equals(portNameNew))
if (portNameNew.Length <= portNames.Length)
{
return null;
}
Array.Sort(portNames);
Array.Sort(portNameNew); //多出的COMx
//foreach (string port in portNames)
for (i = 0; i < portNameNew.Length; i++)
{
for (int j = 0; j < portNames.Length; j++)
{
if (portNameNew[i] == portNames[j])
{
goto GetNext;// break;
}
}
return portNameNew[i];
GetNext:
continue;
}
return null;
}