Image to Stream

I know this is probably an easy question but  I can't figure it out right now.  How can I load an IMAGE into a FILESTREAM so that I can read the imagefile into a bytearray?????

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Use this to read any binary file into a byte array:

using System.IO;


    public byte[] ReadBinaryData(string path)

      FileStream streamBinary = new FileStream(path, FileMode.Open);
      BinaryReader readerInput = new BinaryReader(streamBinary);
      int lengthFile = (int)FileSize(path);

      byte[] inputData = readerInput.ReadBytes(lengthFile);


      return inputData;


    private long FileSize(string path)

      FileInfo fi = new FileInfo(path);

      return fi.Length;


gvector1Author Commented:
The problem is that it is not a file.  It is an Image picture taken with my application and loaded into an image.  I am wanting to convert into a byte array in order to load into a database.
Bob LearnedCommented:
MemoryStream memoryImage = new MemoryStream();

currentImage.Save(memoryImage, Imaging.ImageFormat.Gif);

byte[] imageArray = memoryImage.ToArray();


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.