예제 #1
0
        public static (int?, PortableDevice) GetDevice(string deviceId)
        {
            var devices = new PortableDeviceCollection();

            devices.Refresh();
            var deviceCollection = devices.ToList();
            var device           = deviceCollection.SingleOrDefault(d => string.Equals(deviceId, d.DeviceId, StringComparison.Ordinal));

            if (device == null)
            {
                Console.WriteLine($"[{nameof(EXIT_CODE_DEVICE_NOT_FOUND)}]");
                return(EXIT_CODE_DEVICE_NOT_FOUND, null);
            }

            return(null, device);
        }