博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PC端到WinCE端文件互相拷贝
阅读量:2065 次
发布时间:2019-04-29

本文共 2698 字,大约阅读时间需要 8 分钟。

电脑端 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");

你可能感兴趣的文章
VS判断windows动态链接库是x86还是x64(以vs2015为例)
查看>>
windows下VS2015使用MSVC编译FFmpeg库
查看>>
windows下VS使用FFmpeg被声明为已否决的解决方案
查看>>
Win7 x64环境下Python3.6安装使用提示丢失api-ms-win-crt-runtimel1-1-0.dll
查看>>
c++ Lambda函数
查看>>
c++仿函数
查看>>
C++ STL bind1st和bind2nd
查看>>
windows下Python安装requests
查看>>
目的:解决Ubuntu 使用gedit出现No protocol specified (gedit:14333):
查看>>
解决Ceph集群Mon和OSD网络变更或者ip(主要是mon)变换后,集群不能正常工作问题
查看>>
Python 格式化打印json数据(展开状态)
查看>>
解决windows下libcurl中curl_formadd()的CURLFORM_FILENAME使用中文导致post失败的问题
查看>>
Centos7 安装curl(openssl)和libxml2
查看>>
Centos7 离线安装RabbitMQ,并配置集群
查看>>
Centos7 or Other Linux RPM包查询下载
查看>>
运行springboot项目出现:Type javax.xml.bind.JAXBContext not present
查看>>
Java中多线程向mysql插入同一条数据冲突问题
查看>>
Idea Maven项目使用jar包,添加到本地库使用
查看>>
FastDFS集群架构配置搭建(转载)
查看>>
HTM+CSS实现立方体图片旋转展示效果
查看>>