Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Using the Windows Portable Devices (WDP) API for fun and... fun...

Today's Mobile Monday post is going to be different than most... Instead of Windows Phone 7, etc, we're going to focus on a series of posts that covers an API that many may not know about, but once you do, might get you thinking about the cool stuff you can do with it (I know I am...)

What is this API? The Windows Portable Devices (WDP) API. This is a COM API that is not the most .Net friendly, yet Christophe Geer has a working series of posts that walks you through using it in .Net, from enumeration the content, to grabbing content off, deleting stuff and in the latest post, transfer content from your computer to the device.

What kinds of devices? He shows off examples with cameras and Kindles. So imaging writing some kind of cool utility that explorers, lists, transfers stuff to and from your Kindle. Or building that kind of thing into one of your own app's...

Let's focus on the latest post;

WPD: Transfer Content To A Device

Mayhap came here sooner than I thought. The previous article on the WPD API dealt with deleting resources. Too destructive perhaps, let’s create some resources this time.

My Kindle’s is hooked up to my PC. Let’s see if I can transfer a book to it.

Table Of Contents

TransferContentToDevice Method

Get the source code of the fourth article, #69: WPD: Deleting Resources, from the download page. Unzip it and open it up in Visual Studio.

image

image

In the Solution Explorer select the Program.cs file and open it. Clear the Main(…) method and add the following code to it.

var devices = new PortableDeviceCollection();
devices.Refresh();
var kindle = devices.First();
kindle.Connect();

kindle.TransferContentToDevice(
@"d:\temp\Kindle_Users_Guide.azw",
@"g:\documents");

kindle.Disconnect();

First we establish a connection to the Kindle, copy the book to it and finally disconnect from it

The magic happens in the TransferContentToDevice(…) method, which takes two parameters:

  • fileName: Full path of the file which you want to copy to the device
  • parentObjectId: The ID of the parent folder into which you want to copy the file

Modify the values of these parameters to suit your situation.

Required Properties

Before we can start to implement the TransferContentToDevice(…) method we first need to add another private method to the PortableDevice class type.

....

The post continues into much more depth and details and provides from good geek reading. The other posts in this series are the same, providing simple examples up front and then going into a very nice level of details.

If you've always wanted to build a utility for that portable device, camera, Zune (yes, Zune, I was able to at least get a very raw listing of my Zune HD's content) or Kindle, this is a series of posts you should check out.

Tag:

Follow the Discussion

  • Nice. One question is there a list of all the devices that the  Windows Portable Devices (WDP) API support? Basic on this list I can have an idea of what I want to do.

    Thank,

  • Greg Duncangduncan411 It's amazing what a professional photographer can do...

    @whiteBox85:Not that I have seen...

     

  • slowmonkeyslowmonkey

    If anyone is interested I have created a .net wrapper for the WPD api here: https://github.com/slowmonkey/WPD-.NET-Wrapper

    Also, note that I did use Christopher's original posts and have been in contact with him to cite his work and contributions to the original work with explaining how to use WPD.

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.