Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 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.

like image 397
acadia Avatar asked Mar 31 '10 01:03

acadia


People also ask

How do you create a byte file?

Convert byte[] array to File using Java In order to convert a byte array to a file, we will be using a method named the getBytes() method of String class. Implementation: Convert a String into a byte array and write it in a file. Example: Java.

What is byte in VB net?

The Byte data type holds an integer in the range of 0 to 255. Bytes are frequently used to access binary files, image and sound files, and so on. Note that you no longer use bytes to access individual characters. Unicode characters are stored in two bytes.

How do I use WriteAllBytes file?

WriteAllBytes(String) is an inbuilt File class method that is used to create a new file then writes the specified byte array to the file and then closes the file. If the target file already exists, it is overwritten. Syntax: public static void WriteAllBytes (string path, byte[] bytes);


1 Answers

The easiest way is to use File.WriteAllBytes

Dim img as byte()=dr(0)
File.WriteAllBytes("C:/images/whatever.gif", img)
like image 169
Samuel Neff Avatar answered Sep 30 '22 16:09

Samuel Neff