Home General
Options

Save SQL Image data to file system as jpg files

Just downloaded LINQPad today, and it is an incredible tool. I'm trying to pull binary data out of a table column and store in a local folder as some jpg files, but when I iterate through an IEnumerable result set the files are not getting created, what am I doing wrong? Thanks!

var results = from img in myImageTable join detail in Details on img.DetailId equals detail.ID where img.DetailId == 901 select new {imageData = img.ImageData, imageDate = img.ImageDate, description = img.ImageDescription, name = detail.LastName, nbr = detail.IdNumber }; string filename = "901-"; int I = 0; foreach(var item in results) { i++; filename += i; byte[] bitmap = item.imageData.ToArray(); using(Image image = Image.FromStream(new MemoryStream(bitmap))) { image.Save(fileName, ImageFormat.Jpeg); } }

Comments

Sign In or Register to comment.