---
title: "从PC拷文件至PDA移动设备 windows CE"
author: "starnc"
date: "2009-06-26T10:41:46Z"
tags: []
categories: ["编程语言"]
slug: "pc-pda-windows-ce"
draft: false
lastmod: "2009-06-26T10:41:46Z"
id: 415437
url: "https://starnc.iteye.com/blog/415437"
---

不废话，直接贴代码，因为太简单了。

 

```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using Common.RapiDesktop.Classes;
using OpenNETCF.Desktop.Communication;
namespace TestUSB
{
    public partial class Form1 : Form
    {
        HHFiles myHH; 
        public Form1()
        {
            InitializeComponent();
            
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            RAPI rApi=new RAPI();
            if(rApi.DevicePresent)
            {
                MessageBox.Show("已连接");
                rApi.Disconnect(); 
                myHH = new HHFiles();
                String LocalFileName = @"c:\a.txt";   // 本地计算机文件名 
                String RemoteDeviceFileName = @"\DiskOnChip\a.txt";  // 远程设备文件名
                myHH.CopyFileToDevice(LocalFileName, RemoteDeviceFileName, true);
                MessageBox.Show("文件传输完毕");
                rApi.Disconnect(); 
            }
            else
            {
                MessageBox.Show("未连接");
                rApi.Disconnect(); 
            }
        }
    }
}
```

    在项目中用到了OpenNETCF.Desktop.Communication.DLL和Common.RapiDesktop.Classes.HHFile，这个dll文件是可以在.net中直接引用的，以前的标准dll 如：RAPI.DLL 和 adofiltr.DLL 在.net中调用都比较麻烦。

在[http://www.codeproject.com/KB/mobile/HHFiles.aspx?display=Print](http://www.codeproject.com/KB/mobile/HHFiles.aspx?display=Print)上有HHFile的API文档

在[http://blog.csdn.net/Xus95/archive/2008/06/24/2582931.aspx](http://blog.csdn.net/Xus95/archive/2008/06/24/2582931.aspx) 上，有比较全的各种解释

在[http://msdn.microsoft.com/zh-cn/library/ms837846.aspx#EZAA](http://msdn.microsoft.com/zh-cn/library/ms837846.aspx#EZAA)上有OpenNETCF的API

附件中上传了整个项目。