Solved

VB.net Save image from memory stream

Posted on 2014-07-27
3
841 Views
Last Modified: 2014-07-30
How do I modify the following code to rather save the image as an image file on my hard drive

             Dim oID As String = D.Rows(r).Cells(1).Value
                                Dim sSQL As String = "Select Photo from Photos where ID = " & oID & ""
                                Dim cmd2 As New SqlCommand(sSQL, con)
                                Dim ImgStream As New IO.MemoryStream(CType(cmd2.ExecuteScalar, Byte()))
                                PictureBox1.Image = System.Drawing.Image.FromStream(ImgStream)
0
Comment
Question by:murbro
  • 2
3 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40222901
Hi murbro;

This should work for you.

'' Where locationToSaveTo is a string with the path and filename on the disk.
System.IO.File.WriteAllBytes(locationToSaveTo, CType(cmd2.ExecuteScalar, Byte()));
0
 

Author Closing Comment

by:murbro
ID: 40229541
Thanks very much
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 40229671
Not a problem, glad I was Ble to help.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB: Convert 2 dates to specific format 24 48
Footer for each row on Gridview 2 21
Help with converting xml file to excel using VB.NET 3 20
ASP/VB email question 4 35
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question