vb.net便携式设备问题 [英] vb.net portable device question

查看:60
本文介绍了vb.net便携式设备问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们感谢您的时间和帮助我有这个代码获取名称

便携式设备



guys thanks for time and help i have this code for get name of the
Portable Devices

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.



这个错误发生在代码的粗线上



下一个代码:




this error occurs in the bold line of the code

next the code:

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

< br $> b $ b





如何解决这个问题?





how i can fix this?

推荐答案

这篇关于vb.net便携式设备问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆