Reading images from acess database and writing them to a disk

I have a table named Employees that has an Ole Column named Picture in MS Access 03.  I want to take that image (it has varying types such as .jpg and .bmp) read it from the database and write it to a folder named "Pictures" in the Application root directoy.  How do I do this?  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Open a connection to the database, create a command with a text like SELECT PIC FROM TABLE and execute it using XxxDataReader reader = command.ExecuteReader() method (Xxx is OleDb or ODBC, depending on your connection). Then go over the results using while (reader.Read()) and read the picture using the method

byte[] image = reader.GetValue(0) as byte[];

Then if image is != null, save it to a file in the folder you want.
CDFA_IncAuthor Commented:
I understand the conversions.  I am curious as to how to write the byte array to file.  First of all the pictures in the database are of varying types.  How do you account for the title and extension of the pics.  Please post an example.
The fact that you pictures have different types means that you have to read the data and examine it to find out what kind of file this is. Every picture file type has a specific structure, so if you know there will be JPEG and BMP files, you should check if the format is what JPEG expects and if not check for BMP. You can find more info about the file formats online, using google. The application AcdSee succeeds to do this - make a test by changing the extention of a JPEG to BMP and see that AcdSee will still show that the file is a JPEG file.

This is a link how to write byte array to a file. There are some additional links about file operations on this page:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.