开发者

Creating a file based on the byte() in VB.NET

I am retrieving an image from the SQL database into Byte() variable in VB.NET.

Dim img as byte() = dr(0)

How do I crea开发者_如何学编程te 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.


The easiest way is to use File.WriteAllBytes

Dim img as byte()=dr(0)
File.WriteAllBytes("C:/images/whatever.gif", img)


System.IO.File.WriteAllBytes(@"c:\whatever.txt", bytes)


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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜