读取PDA目录的内容,同时与ActiveSync同步 [英] Reading the content of a PDA directory while sync with ActiveSync

查看:219
本文介绍了读取PDA目录的内容,同时与ActiveSync同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目中,我需要复制一个PDA中找到的文件(对我来说,这是一个MC3000如果让任何区别)。我安装ActiveSync和它创造的syncronisation文件夹给我就好了。不过,我希望能够读取PDA的内容不仅在于其myDocument中的文件夹,所以我不能用这个(再加上它有同型号的20 +可能的PDA的工作,从而使20 +目录)

I have a project in which I would need to copy files found within a PDA (in my case, it's a MC3000 if that makes any difference). I have ActiveSync installed and it create the syncronisation folder for me just fine. However, I would like to be able to read the content of the PDA not only in its MyDocument Folder so I can't use this (Plus it have to work with 20+ possible PDA of the same model, thus making 20+ directory)

有没有办法做一些IO的PDA里面,而它停靠并与ActiveSync的同步即是。

Is there a way to do some IO inside the PDA, while it is docked and sync with ActiveSync that is.

我可以看到在资源管理器中的移动设备。

I can see the 'Mobile Device' in Explorer.

感谢

推荐答案

使用 RAPI 。这是一个codePLEX项目,提供托管包装类文件Rapi.dll 和ActiveSync。它可以让桌面.NET应用程序使用系留的移动设备进行通信。包装发源 OpenNetCF项目的内,但现在单独管理。

Use RAPI. It's a codeplex project that provides managed wrapper classes for Rapi.dll and ActiveSync. It lets desktop .NET apps communicate with tethered mobile devices. The wrapper originated within the OpenNetCF project, but is now managed separately.

您可以使用整个RAPI项目的DLL,因为船只从该项目,或只使用code您需要的子集。我需要的时候它连接的设备上创建的文件,所以我并不需要性能统计的东西,或者包含在RAPI设备注册表的东西。所以,我只是抓住了3源文件,我需要......

You can use the whole RAPI project DLL as it ships from that project, or just use the subset of code that you need. I needed to create files on the device when it connected, so I didn't need the performance statistics stuff, or the device registry stuff that is included in Rapi. So I just grabbed the 3 source files I needed...

它为我工作的方式,是这样的:

The way it works for me, is this:

  • 使用ActiveSync的(DccManSink)来检测移动设备的连接/断开状态
  • 使用RAPI的包装将文件复制到设备,在设备上创建文件,从设备复制文件,等等。
private DccMan DeviceConnectionMgr;
private int AdviceCode;
private int ConnectionStatus = 1;
private System.Threading.AutoResetEvent DeviceConnectionNotification = new System.Threading.AutoResetEvent(false);


public void OnConnectionError()
{
    ConnectionStatus = -1;
    DeviceConnectionNotification.Set();
}

public void OnIpAssigned(int address)
{
    ConnectionStatus = 0;
    DeviceConnectionNotification.Set();
}


private void btnCopyToDevice_Click(object sender, EventArgs e)
{
    // copy the database (in the form of an XML file) to the connected device
    Cursor.Current = Cursors.WaitCursor;

    // register for events and wait.
    this.DeviceConnectionMgr = new DccMan();

    DccManSink deviceEvents = new DccManSink();
    deviceEvents.IPChange += new IPAddrHandler(this.OnIpAssigned);
    deviceEvents.Error += new ErrorHandler(this.OnConnectionError);
    ((IDccMan)DeviceConnectionMgr).Advise(deviceEvents, out this.AdviceCode);

    // should do this asynchronously, with a timeout; too lazy.
    this.statusLabel.Text = "Waiting for a Windows Mobile device to connect....";

    this.Update();
    Application.DoEvents();  // allow the form to update

    bool exitSynchContextBeforeWait = false;
    DeviceConnectionNotification.WaitOne(SECONDS_TO_WAIT_FOR_DEVICE * 1000, exitSynchContextBeforeWait);

    if (ConnectionStatus == 0)
    {
        this.statusLabel.Text = "The Device is now connected.";
        this.Update();
        Application.DoEvents();  // allow the form to update

        RAPI deviceConnection = new RAPI();
        deviceConnection.Connect(true, 120);  // wait up to 2 minutes until connected
        if (deviceConnection.Connected)
        {
            this.statusLabel.Text = "Copying the database file to the connected Windows Mobile device.";
            this.Update();
            Application.DoEvents();  // allow the form to update
            string destPath = "\\Storage Card\\Application Data\\MyApp\\db.xml";
            deviceConnection.CopyFileToDevice(sourceFile,
                                              destPath,
                                              true);

            this.statusLabel.Text = "Successfully copied the file to the Windows Mobile device....";
        }
        else
        {
            this.statusLabel.Text = "Oh, wait, it seems the Windows Mobile device isn't really connected? Sorry.";
        }

    }
    else
    {
        this.statusLabel.Text = "Could not copy the file because the Device does not seem to be connected.";
    }

    Cursor.Current = Cursors.Default;

}

这篇关于读取PDA目录的内容,同时与ActiveSync同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆