File transfer from device to pc

Last post 07-24-2008 13:13 by sinseven. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 06-27-2008 7:11

    File transfer from device to pc

    Hi,

    I can send file from pc to device using opennetcf.desktop.communicaiton.

    But i wonder how i can do this for device?

    I haven't seen any function like this in this dll?

    What are your suggestions?

    Thanks in advance.

     

  • 06-27-2008 8:41 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: File transfer from device to pc

    There is a method in the RAPI class that will allow to copy a file from a device to the PC where the code is running. It's called CopyFileFromDevice and is the counterpart to CopyFileToDevice.


  • 06-28-2008 0:51 In reply to

    Re: File transfer from device to pc

    Hi,

    Thanks.

    I have noticed this command.But i want to triggle this process from device and i wonder if it is possible or not to use this library in compact framework 2.

    Thanks.

  • 06-28-2008 1:42 In reply to

    • Neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,152

    Re: File transfer from device to pc

    No, there isn't a way and I doubt there ever will be. The security implications of allowing this are quite obvious. 


  • 06-28-2008 9:10 In reply to

    Re: File transfer from device to pc

    In this given code M getting "Could not open remote file error" ... i had tried all solution given in this all forums of OPNENETCF but None of this working in my code... plz help me ... thnx in Advance

     

    Imports OpenNETCF.Desktop.Communication.

     ublic Class FrmMain
        ' Declare an instance of the RAPI object.
        Dim WithEvents myrapi As New RAPI

        Private Sub BtnCheckForConn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCheckForConn.Click
            Try
                ' Connect to the device.
                myrapi.Connect()
                Do While Not myrapi.DevicePresent
                    MessageBox.Show("Please connect your device to your PC using ActiveSync and " & _
                      "before clicking the OK button.", "No Device Present")
                    Application.Exit()
                    myrapi.Connect()
                Loop

            Catch ex As Exception
                MessageBox.Show("The following error occurred while attempting to connect to" & _
                  " your device - " & ex.Message, "Connection Error")
                Application.Exit()
            End Try
            MsgBox("PDA Connected")
        End Sub


        Private Sub BtnPCtoPDA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPCtoPDA.Click
            ' Perform the copy.
            Try
                If (txtCopySource.Text = "") Or (txtCopyDestination.Text = "") Then
                    MessageBox.Show("You must provide both a source and destination file.", _
                      "Missing File Information")
                    Exit Sub
                End If

                myrapi.CopyFileToDevice(txtCopySource.Text, txtCopyDestination.Text)

             
                MessageBox.Show("Your file has been copied.", "Copy Success")

                ' Handle any errors that might occur.
            Catch ex As Exception
                MessageBox.Show("The following error occurred copying the file -" & ex.Message, _
                  "Copy Error")
            End Try
        End Sub

        Private Sub BtnPDAtoPC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPDAtoPC.Click
            Try
                If (txtCopySource.Text = "") Or (txtCopyDestination.Text = "") Then
                    MessageBox.Show("You must provide both a source and destination file.", _
                      "Missing File Information")
                    Exit Sub
                End If
                'myrapi.CopyFileFromDevice(txtCopySource.Text, txtCopyDestination.Text)

                myrapi.CopyFileFromDevice("C:\PDA\e.doc", "\My Documents\e.doc", True)
                MessageBox.Show("Your file has been copied.", "Copy Success")

                ' Handle any errors that might occur.
            Catch ex As Exception
                MessageBox.Show("The following error occurred copying the file -" & ex.Message, _
                  "Copy Error")
            End Try

        End Sub

        Private Sub BtnMoevFrmPCtoPDA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnMoevFrmPCtoPDA.Click
            ' Perform the copy.
            Try
                If (txtCopySource.Text = "") Or (txtCopyDestination.Text = "") Then
                    MessageBox.Show("You must provide both a source and destination file.", _
                      "Missing File Information")
                    Exit Sub
                End If

                myrapi.MoveDeviceFile(txtCopySource.Text, txtCopyDestination.Text)

                MessageBox.Show("Your file has been copied.", "Copy Success")

                ' Handle any errors that might occur.
            Catch ex As Exception
                MessageBox.Show("The following error occurred copying the file -" & ex.Message, _
                  "Copy Error")
            End Try
        End Sub

        Private Sub BtnMoevFrmPDAtoPC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnMoevFrmPDAtoPC.Click
            Try
                If (txtCopySource.Text = "") Or (txtCopyDestination.Text = "") Then
                    MessageBox.Show("You must provide both a source and destination file.", _
                      "Missing File Information")
                    Exit Sub
                End If
                myrapi.MoveDeviceFile(txtCopySource.Text, txtCopyDestination.Text)
                MessageBox.Show("Your file has been copied.", "Copy Success")

                ' Handle any errors that might occur.
            Catch ex As Exception
                MessageBox.Show("The following error occurred copying the file -" & ex.Message, _
                  "Copy Error")
            End Try
        End Sub
    End Class
     

    Filed under:
  • 06-28-2008 9:36 In reply to

    Re: File transfer from device to pc

     Now not to worry for "could not open remote  file error" ... I had done all the Solution given in this community but none of them worked for me but at last the solution is

    u just need to replace

    myrapi.CopyFileFromDevice("C:\Test.doc", "\My Documents\Test.doc", True) line code to

    myrapi.CopyFileFromDevice("C:\\Test.doc", "\\My Documents\\Test.doc", True) ...  now :)

     

  • 07-24-2008 13:13 In reply to

    Re: File transfer from device to pc

    Yes, you can't use \ like that, unless you put a @ in front of the quotes. It tells the string to not escape.

     

    ie.  myrapi.CopyFileFromDevice(@"C:\Test.doc", @"\My Documents\Test.doc", True) would work fine.

Page 1 of 1 (7 items)