Reputation: 2621
I am retrieving an image from the SQL database into Byte() variable in VB.NET.
Dim img as byte() = dr(0)
How do I create a file in my C:\images\ directory from the above img.
I want to read the img and then create a file with name bimage.gif.
Upvotes: 11
Views: 41334
Reputation: 74909
The easiest way is to use File.WriteAllBytes
Dim img as byte()=dr(0)
File.WriteAllBytes("C:/images/whatever.gif", img)
Upvotes: 19
Reputation: 22158
Try:
Dim ms as MemoryStream = New MemoryStream(img)
Dim bmp as Bitmap = CType(Bitmap.FromStream(ms), Bitmap)
bmp.Save(@"C:\images\name.gif", ImageFormat.Gif);
bmp.Dispose()
ms.Dispose()
Upvotes: 2