我目前正在使用OpenNETCF.Desktop.Communication.dll将文件从我的桌面复制到CE设备,但我一直收到错误:

‘无法创建远程文件’

我的开发环境是VS2005(VB.NET)

我的代码:

ObjRapi.Connect()
ObjRapi.CopyFileToDevice("C:\results.txt", "\results.txt")
ObjRapi.Dispose()
ObjRapi.Disconnect()

有没有人碰到这个并且你设法绕过它。

由于

有帮助吗?

解决方案

我之前遇到过这个问题,但我真的不记得是什么造成了它。

通过查看代码我唯一能想到的就是这一行:

ObjRapi.CopyFileToDevice("C:\results.txt", "\ \results.txt") 

我不确定但您可以尝试将目标路径更改为不同的路径。像这样:

ObjRapi.CopyFileToDevice("C:\results.txt", "\My Documents\results.txt")

我现在无法对此进行测试,但我真的不明白为什么它不会起作用。

编辑:我刚看了一些使用RAPI编写的代码,当我进行任何复制时,我的行看起来像这样:

ObjRapi.CopyFileToDevice("C:\results.txt", "\My Documents\results.txt",True)

末尾的布尔值是一个覆盖开关,将其设置为true可能有效。

其他提示

试试这个

将myrapi视为新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

您必须使用以下代码:

op.CopyFileToDevice(@"C:\results.txt", @"\Temp\results.txt");

在您的代码中,您没有提到要复制文件的路径。

希望这会对你有所帮助。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top