csrivera
csrivera

Reputation: 53

Pulling files from a Windows Mobile device via ActiveSync

I would like know how can I move a file from a my Handheld device to some Windows folder, across the USB Sync. ej.

from a \MyDevice\some.txt copy to C:\Temp\some.txt in C# or VB or C++.

I'm new in develop in this device. Can someone help me with this.

Upvotes: 0

Views: 1014

Answers (2)

Seva Alekseyev
Seva Alekseyev

Reputation: 61331

I'm assuming it's a Windows Mobile device; there's no other mobile devices (for now) that Visual C++ can be used with.

You cannot do it from the device side; allowing the mobile device to mess with the host's filesystem would be a huge security risk.

From the Windows side, you can use the RAPI functions CeCopyFile() or CeCreateFile()/CeReadFile(), when the device is connected to the PC via ActiveSync. Also you can pull files via the Core Connectivity API, but it's considerably more tricky; you'll have to use the CoreCon interface ICcConnection.

The RAPI header and library come with a Windows Mobile SDK, pretty much any version.

EDIT: so you need it from the device side. No built-in API for that. Consider ActiveSync. It has an interface for automatically syncing a host folder with a device folder; if the files change on the device, the changes will be automatically pulled to the PC. If you implement a custom item interface, you can notify ActiveSync of changes as they happen.

Think of it this way. Pushing files with no active cooperation from the host PC is impossible; you gotta realize how much of a disaster it would be otherwise; anyone with a device and a USB cable would be able to take over an arbitrary PC by just plugging the device in. But, if you're working on getting cooperation from a host PC, you might as well put together a RAPI program for Windows that polls a certain folder on the device and pulls files.

Or you can set up an FTP server on the host PC, like ctacke suggests.

Upvotes: 3

ctacke
ctacke

Reputation: 67168

If you need to push from the device to the PC, you'll have to have a service on the PC running to accept the request and data, for example an FTP server. When connected, you get a local virtual network and resolving "ppp_peer" will get you the connected PC. At that point you could push to a local web service, FTP or whatever. There's no way to transfer it directly to the file system without some explicit service, however, because that would be a gigantic security hole.

Upvotes: 1

Related Questions