2017-05-23 102 views
0

私はVB.NETを使用してビデオコピーアプリケーションを作成しています。必要なファイルをパスからUSBに簡単にコピーできますが、携帯電話などのポータブルデバイスでも同じことをするのに問題があります。パスからWPDまたはMTPデバイスにファイルをコピーする方法

これまでのところ、questionに記載されているコードと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 

答えて

0

あなたはあなたが必要なすべての情報が含まれているあなたの前のトピックにgreateのanswerを持って次のように

これに関連し、サブの私のコードです。

ここでは、ポータブルデバイスを学習する必要があります。documentation、プログラミングガイド - >デバイスコンテンツで操作する。そこには、PCからデバイスへのコピーファイルのサンプルを見つけることができます。

linkからサンプルプロジェクト全体をダウンロードすることもできます。コンテンツ転送のサンプルが含まれています。

つまり、転送するファイルデータを含むストリームオブジェクトを作成し、コンテンツオブジェクトからCreateObjectWithPropertiesAndDataメソッドを使用し、コンテンツから受け取ったストリームにストリームデータをコピーする必要があります。

すべてのデータがコピーされた後、IPortableDeviceDataStreamからCommitを呼び出して、ドライバが終了したことを知らせます。

関連する問題