RAPI copy file using OpenNETCF.Desktop.Communication.dll
Question
I’m currently using the OpenNETCF.Desktop.Communication.dll to copy files from my desktop to a CE device, but I keep getting an error:
‘Could not create remote file’
My development environment is VS2005 (VB.NET)
My code:
ObjRapi.Connect()
ObjRapi.CopyFileToDevice("C:\results.txt", "\results.txt")
ObjRapi.Dispose()
ObjRapi.Disconnect()
Has anyone run into this and did you manage to get around it.
Thanks
Solution
I have run into this once before but I can't really remember what was causing it.
The only thing I can think of from looking at your code is this line:
ObjRapi.CopyFileToDevice("C:\results.txt", "\ \results.txt")
I'm not sure but you could try and change the destination path to something different. Something like this:
ObjRapi.CopyFileToDevice("C:\results.txt", "\My Documents\results.txt")
I can't really test this at the moment but I really don't see why it wouldn't work.
EDIT: I just had a look at some code that I have writen using the RAPI,when I do any copying my line looks like this:
ObjRapi.CopyFileToDevice("C:\results.txt", "\My Documents\results.txt",True)
The boolean on the end is an overwrite switch, setting that to true may work.
OTHER TIPS
try this
Dim myrapi As New RAPI
If myrapi.DevicePresent = True Then
myrapi.Connect()
If myrapi.Connected = True Then
Windows.Forms.Cursor.Current = Cursors.WaitCursor
If myrapi.DeviceFileExists("\Backup\stock.txt") Then
myrapi.CopyFileFromDevice(Application.StartupPath
Windows.Forms.Cursor.Current = Cursors.Default
MessageBox.Show("File Copied Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
Else
MessageBox.Show("Please Connect to the Mobile Device", "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
End If
Else
MessageBox.Show("Please Connect to the Mobile Device", "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
You have to use the following code:
op.CopyFileToDevice(@"C:\results.txt", @"\Temp\results.txt");
In your code you are not mentioning the path where you want to copy the file.
Hope this will help you.