A client has asked us to write a little Windows Forms app that will take the pictures on a digital camera and transfer them to a folder on the hard drive. No sweat, we thought – it’s very easy to transfer files and folders using the System.IO namespace – files on devices will surely function similarly.
But we searched and searched and Googled and Googled, and came up empty. Finally we found this blog entry, which is apparently the definitive authority about using an old COM component called Windows Image Acquisition (WIA) to work with cameras and scanners:
(Important Note: if you don’t have a device connected when you try to run the code that opens the dialog box, you will get an error that looks like this:
Exception from HRESULT: 0x80210015
at WIA.CommonDialogClass.ShowSelectDevice(...) )
In the course of trying to work with WIA, we also found an MSDN entry (which has a lot of info but code samples are in C++) and a couple more posts with additional information:
- WIA (MSDN)
- WIA (MS Dev Center)
- Discussion around the Coding4Fun Some Assembly Required Articles
- WIA.ImageFile to System.Drawing.Image (code sample)
- WIA 2.0 Image Deletion (more code samples)
Perhaps there is a more modern, .NET managed code way to do this, but until I find it, I thought I’d better have these links handy!!