• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

image field in sql database convert to actual files

I have a bunch of binary data in my database in a image fields... I want to convert the binary files to
ACTUAL FILES  that i can save in a folder... can somebody tell me how to do this?

I will do this where datareader is the image field

 Do while
    dr("imagefield") 'DO SOMETHING
loop



0
vbnetcoder
Asked:
vbnetcoder
  • 3
  • 2
1 Solution
 
käµfm³d 👽Commented:
Unless I'm way off, the data should be coming back as a byte array [ Byte() ]. You could load that into a Stream for writing (this is an overview; you'll need to tweak it):
Do While
    Using ms As New System.IO.MemoryStream(DirectCast(dr("imagefield"), Byte()))
        Using img As Image = Image.FromStream(ms)
            img.Save("someFilename.someExt")
        End Using
    End Using
Loop

Open in new window

0
 
vbnetcoderAuthor Commented:
That worked, Thank you!  Can you tell how I can tell for sure that there is a image?  Some fields may return as null.

Thank you
0
 
vbnetcoderAuthor Commented:
Never mind i got it
0
 
vbnetcoderAuthor Commented:
ty
0
 
käµfm³d 👽Commented:
NP. Glad to help  = )
0
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now