locked
OpenNetCF Problems in VS 2005 VB.NET RRS feed

  • Question

  • Working with an MSDN example of OpenNetCF wrapper of the RAPI class http://msdn2.microsoft.com/en-us/library/ms839349.aspx I have not been able to copy a file from the pocket pc to the desktop PC.  In addition, the device present check does not evaluate (hangs on statment)  if the device is not connected but works fine if it is connected.

     

    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")
        myrapi.Connect()
      Loop

    myrapi.CopyFileFromDevice("\work.doc", "c:\work.doc")

     

    When the above copy statement executes I get a simple exception error "Could not Open remote file."   I can browse to the file in Windows Explorer. 

     

    I installed OpenNETCF v 2.9  & ActiveSync 4.5,  developing in VS 2005 SP1.  This seems to be a pretty simple example I am wondering if I am missing somthing.

    Monday, December 31, 2007 4:51 PM

Answers

  • Hi klrklr,

    Please check:

    1. whether the path has the work.doc file.
    2. Please try to use \\work.doc and "c:\\work.doc"

    You can use RAPI RAPIConnected and RAPIDisconnected  event to detect whether activesync is connected.

     

    Like the code below:

    Code Block

    private void connectAsync_Click(object sender, System.EventArgs e)

                    {

                            m_rapi.RAPIConnected += new RAPIConnectedHandler(m_rapi_RAPIConnected);

                            m_rapi.RAPIDisconnected += new RAPIConnectedHandler(m_rapi_RAPIDisconnected);

                            m_rapi.Connect(false, -1);

                    }

     

                    private void m_rapi_RAPIConnected()

                    {

                this.Invoke(textUpdate, new object[] { this, new TextArgs(connectStatus, "Connected") });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectSync, false) });

                    }

     

                    private void m_rapi_RAPIDisconnected()

                    {

                this.Invoke(textUpdate, new object[] { this, new TextArgs(connectStatus, "Not Connected") });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });

                    }

     

     

                    private void copyFrom_Click(object sender, System.EventArgs e)

                    {

                            if(! m_rapi.Connected)

                            {

                                    MessageBox.Show("Not connected!");

                                    return;

                            }

     

                            m_rapi.CopyFileFromDevice("f:\\1.jpg", "\\My Documents\\1.jpg", true);

     

                    }

     

     

    There is a completed sample in Opennetcf website:

    http://www.opennetcf.org/getfile.asp?file=Communication&dir=src

     

    By the way, my code is written using c#, you can convert to vb.net via following site:

    http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx

     

     

    Best regards,

    Guang-Ming Bian - MSFT

    Wednesday, January 2, 2008 4:49 AM
  • I got it working.

     

    The problem was I had the local and remote filenames switched.  Thanks for your help.

     

     

    Wednesday, January 2, 2008 7:15 PM

All replies

  • Check the process list to see if the document is in use by Pocket Word.

     

    I use this library for RAPI stuff.

    http://www.tmssoftware.com/

     

    Click on PocketPC and they have a RAPI wrapper this works great.

     

     

    Monday, December 31, 2007 5:13 PM
  • The only process running is ActiveSync.  I have also tried other functions in the library with mixed results. 

     

    Thanks for the reply.

     

    Monday, December 31, 2007 5:34 PM
  • Hi klrklr,

    Please check:

    1. whether the path has the work.doc file.
    2. Please try to use \\work.doc and "c:\\work.doc"

    You can use RAPI RAPIConnected and RAPIDisconnected  event to detect whether activesync is connected.

     

    Like the code below:

    Code Block

    private void connectAsync_Click(object sender, System.EventArgs e)

                    {

                            m_rapi.RAPIConnected += new RAPIConnectedHandler(m_rapi_RAPIConnected);

                            m_rapi.RAPIDisconnected += new RAPIConnectedHandler(m_rapi_RAPIDisconnected);

                            m_rapi.Connect(false, -1);

                    }

     

                    private void m_rapi_RAPIConnected()

                    {

                this.Invoke(textUpdate, new object[] { this, new TextArgs(connectStatus, "Connected") });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectSync, false) });

                    }

     

                    private void m_rapi_RAPIDisconnected()

                    {

                this.Invoke(textUpdate, new object[] { this, new TextArgs(connectStatus, "Not Connected") });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });

                this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });

                    }

     

     

                    private void copyFrom_Click(object sender, System.EventArgs e)

                    {

                            if(! m_rapi.Connected)

                            {

                                    MessageBox.Show("Not connected!");

                                    return;

                            }

     

                            m_rapi.CopyFileFromDevice("f:\\1.jpg", "\\My Documents\\1.jpg", true);

     

                    }

     

     

    There is a completed sample in Opennetcf website:

    http://www.opennetcf.org/getfile.asp?file=Communication&dir=src

     

    By the way, my code is written using c#, you can convert to vb.net via following site:

    http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx

     

     

    Best regards,

    Guang-Ming Bian - MSFT

    Wednesday, January 2, 2008 4:49 AM
  • I got it working.

     

    The problem was I had the local and remote filenames switched.  Thanks for your help.

     

     

    Wednesday, January 2, 2008 7:15 PM