C# and WIA - Deleting Images

G

greyseal

I've gone around and around this thing for the last day or so.

Using WIA, I can take and copy images from my Nikon D2H. However, when
I attempt to delete the image I find that that capability is not
supported. So I figured I'd just use System.IO functions (File.Delete)
to do it except that except for the OpenFileDialog component, none of
the functions can see the camera folder. If I access the pictures
using OFD then I get a file/path not found exception.

So a) how can I access this camera folder that I can see in Explorer
or the open file dialog and b) and how can I delete these photos from
the CF card in the camera?

Thanks for any suggestions (just what is System.IO.IsolatedStorage
anyway?)...

greyseal
 
M

Michael Culley

I've had the WIA delete function working in C#. Are you using the wiaaut.dll library?
 
G

greyseal

Michael,

Actually, the code I am using is derived from Thomas Scheidegger's
(NETMaster) code at Code Project
(http://www.codeproject.com/dotnet/wiascriptingdotnet.asp) which is
WIA scripting. Do you have some example code you'd care to share for
a) taking a picture, b) copying it to the PC, and c) deleting one or
all images from the camera (CF card)?

WIA scripting seems to allow me to do a) and b) but c) raises an error
that this function is not supported - but I can delete the images from
Windows Explorer and using the Camera and Scanner wizard (neither of
which is acceptable to my users).

As an aside, I've spent three weeks trying to schlep through Nikon's
SDK documentation and their single sample program (a C/C++ console
app) and only managed to accomplish step a) (take picture). I'm
starting to run up against deadlines now...

Any help would be appreciated!

greyseal
 
M

Michael Culley

greyseal said:
Actually, the code I am using is derived from Thomas Scheidegger's
(NETMaster) code at Code Project
(http://www.codeproject.com/dotnet/wiascriptingdotnet.asp) which is
WIA scripting. Do you have some example code you'd care to share for
a) taking a picture, b) copying it to the PC, and c) deleting one or
all images from the camera (CF card)?

I'm using the WIA Automation dll which I think is a wrapper on top of what you are using, basically it's a com wrapper for a com
wrapper. :) I think it has less functionality but is much easier to use, certainly just getting the pictures stored in a camera (and
deleting them) was very easy. Have a look at these links

http://msdn.microsoft.com/library/d...wiaaut/wia/wiax/overviews/startpagewiaaut.asp

http://www.microsoft.com/downloads/...7a-01b8-4de6-91c2-b7ea32537e29&DisplayLang=en

When distributing your app you just need to put the wiaaut.dll file in the system directory and register it. The only problem is
that it required XP to have sp1 applied.
 
G

greyseal

Michael,

Thanks again for the prompt reply. After I read your first post I went
back and reviewed the MSDN docs again on WIA and realized my problem
(variant types with a COM object). I saw some VB examples and noted
that they had declared the variables as Dim device 'As Device where
the "As Device" part was commented out and I suddenly understood what
I had been reading on some other threads about variants used in the
COM space.

To make a long story short, it's working fine now. Thanks for your
assist - now I can get back to coding!

greyseal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top