从PC拷文件至PDA移动设备 windows CE

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

 

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上有HHFile的API文档

http://blog.csdn.net/Xus95/archive/2008/06/24/2582931.aspx 上,有比较全的各种解释

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

附件中上传了整个项目。





已有 0 人发表留言,猛击->>这里<<-参与讨论


JavaEye推荐



posted @ 2009-06-26 10:42  老子不服  阅读(1157)  评论(0)    收藏  举报