when i have a portable devices connected to the pc works fine but when i disconnected the portables devices i get this error: index was outside the bounds of the array.
Imports System.Collections.ObjectModel Imports PortableDeviceApiLib Namespace PortableDevices Public Class PortableDeviceCollection Inherits Collection(Of PortableDevice) Private ReadOnly _deviceManager As PortableDeviceManager Public Sub New() Me._deviceManager = New PortableDeviceManager() End Sub Public Sub Refresh() Me._deviceManager.RefreshDeviceList() Dim deviceIds = New String(0) {} Dim count_Renamed As UInteger = 1 Me._deviceManager.GetDevices(deviceIds(0), count_Renamed) deviceIds = New String(count_Renamed - 1) {} Me._deviceManager.GetDevices(deviceIds(0), count_Renamed) For Each deviceId In deviceIds Add(New PortableDevice(deviceId)) Next deviceId End Sub End Class End Namespace
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)