我正在使用 VB.NET 创建视频复制应用程序。我可以轻松地将所需的文件从路径复制到 USB,但我在使用手机等便携式设备时遇到了麻烦。
到目前为止,我能够使用此问题中给出的代码和 DLL 找到并连接手机,但我无法将文件复制到设备。
我与此相关的子代码如下:
Imports System.IO
Imports PortableDevices
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox("Please make sure that your device is connected! Press ok to continue", MsgBoxStyle.OkOnly)
For Each item In listID.Items
table = Universal.convertType(item.ToString.Remove(6), 1)
colInitials = Universal.getStringUntilChar(table, "_")
'Code to get the file path stored in sql and store it as filePath
Dim filePath As New DirectoryInfo(SQL.getRecordedValue(table,
colInitials & "Location", colInitials & "ID", item.ToString.Remove(0, 6)))
Dim folderName As String = filePath.Name
' build collection for the devices
Dim pds As New PortableDeviceCollection
' get dev list
pds.Refresh()
For Each device In pds
' connect before doing stuff
device.Connect()
' find out what treasures are stored here
Dim root = device.GetContents()
' the root is the startingm root folder
'Dont know what to do here
' disconnect from this device
device.Disconnect()
Next
pds.First.Disconnect()
Next
End Sub