Port name can not be empty

Apr 16, 2011 at 11:40 AM

Hello.

On any machines i get "Port name can not be empty" (free translatet from german) exception. Please build in a check of the newName parameter in RenameDevice function:

        /// <summary>
        /// Renames the specified serial device, only if there is not already another serial device with the specified name.
        /// </summary>
        /// <param name="device">The device to be renamed.</param>
        /// <param name="newName">The new name for the device.</param>
        private static void RenameDevice(SerialDevice device, string newName)
        {
            // Make sure this port isn't already opened by another device
            if (!String.IsNullOrEmpty(newName))
            {
                for (int existingDevice = 0; existingDevice < _SerialDevices.Count; existingDevice++)
                {
                    if (_SerialDevices[existingDevice].Port.Equals(newName, StringComparison.OrdinalIgnoreCase))
                    {
                        return;
                    }
                }

                device.Port = newName;
                device.SetName(newName);
            }
        }