B
Ben Willett
I have a C#/ASP.NET/ADO.NET/SQL Server app that stores and retrieves images.
The problem is the ASP Image control binds to a file. When retrieving an image from SQL, I would really like to avoid saving the ByteStream/FileStream to disk, just to then read it back into the Image control.
Is there a way to avoid this?
// This is my current implentation. It works, but requires lots of disk i/o.
// Write the ByteArray to a FileStream and then the FileStream to disk.
iLen = mySqlDataReader.GetBytes(0, 0, myByteArray, 0, lBufSize);
FileStream myFS = new FileStream(@"c:\image.jpg", FileMode.Create, FileAccess.Write);
myFS.Write(myByteArray, 0, iLen);
ASPImage1.ImageUrl = @"c:\image.jpg";
Thanks in advance,
Ben
The problem is the ASP Image control binds to a file. When retrieving an image from SQL, I would really like to avoid saving the ByteStream/FileStream to disk, just to then read it back into the Image control.
Is there a way to avoid this?
// This is my current implentation. It works, but requires lots of disk i/o.
// Write the ByteArray to a FileStream and then the FileStream to disk.
iLen = mySqlDataReader.GetBytes(0, 0, myByteArray, 0, lBufSize);
FileStream myFS = new FileStream(@"c:\image.jpg", FileMode.Create, FileAccess.Write);
myFS.Write(myByteArray, 0, iLen);
ASPImage1.ImageUrl = @"c:\image.jpg";
Thanks in advance,
Ben