关闭

PC端到WinCE端文件互相拷贝

标签: windows mobilewincec#
1069人阅读 评论(0) 收藏 举报
分类:


电脑端 Windows Mobile 设备中心必须可以连接到手持设备



首先需要引用 OpenNETCF.Desktop.Communication  

源代码下载地址如下 https://social.msdn.microsoft.com/Forums/en-US/8344cb0d-3891-4eab-a62b-4af5a7ee32ad/c-opennetcf-copyfiletodevice-copyfilefromdevice-windows-7-wmdc?forum=netfxcompact


测试程序界面如下,在拷贝前需要先点击连接。

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenNETCF.Desktop.Communication;

namespace CopyFileToWinCE
{
    public partial class Form1 : Form
    {
        RAPI myrapi = new RAPI ();

        public Form1()
        {
            InitializeComponent();
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            myrapi.Connect();
            while (!myrapi.DevicePresent)
            {
                MessageBox.Show("Please connect your device to your PC using ActiveSync and before clicking the OK button.",
                  "No Device Present");
                myrapi.Connect();
            }
        }

        private void btnCopyFile_Click(object sender, EventArgs e)
        {
              try
                {
                 if ((txtCopySource.Text == "") || (txtCopyDestination.Text == ""))
                  {
                     MessageBox.Show("You must provide both a source and destination file.",
                         "Missing File Information");
                  }
                   else
                 {
                   switch (cmbCopyDirection.Text)
                     {
                        case "":  MessageBox.Show("You must select a direction before initiating the copy.", "No Destination Selected");
                        break;
                        case "from desktop to device": myrapi.CopyFileToDevice(txtCopySource.Text, txtCopyDestination.Text);
                        MessageBox.Show("Your file has been copied.", "Copy Success");
                        break;
                        case "from device to desktop":
                        myrapi.CopyFileFromDevice(txtCopySource.Text, txtCopyDestination.Text);
                        MessageBox.Show("Your file has been copied.", "Copy Success");
                        break;
                    }
                }  
              }
              catch (Exception ex)
               {
                    MessageBox.Show("The following error occurred copying the file -" + ex.Message,  "Copy Error");
               }
        }
        


    }
}
为程序创建桌面快捷方式
            myrapi.CreateDeviceShortcut(@"\Windows\桌面\扫描系统3190.lnk", @"Platform\ScanBarcode\3190\ScanBarcode3190.exe");
            myrapi.CreateDeviceShortcut(@"\Windows\桌面\无线扫描系统W3190.lnk", @"Platform\ScanBarcode\W3190\ScanBarcodeW3190.exe");


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:274417次
    • 积分:4248
    • 等级:
    • 排名:第7454名
    • 原创:150篇
    • 转载:51篇
    • 译文:0篇
    • 评论:15条
    最新评论