convert byte type to jpeg

Posted by Klbaiju under ASP.NET on 7/20/2012 | Points: 10 | Views : 1163 | Status : [Member] | Replies : 2
hi,

in my application images are stored as byte types.I want to convert byte type to jpeg type an save all in a directory.

how it is possible.

Regards

K L BAIJU




Responses

Posted by: Rchennaiah on: 7/20/2012 [Member] Starter | Points: 25

Up
0
Down
int ArraySize = new int();
bool bReturnvalue = false;
byte[] byteData = new byte[0];
SQLConnection con=new SQLConnection("Connectionstring");
try
{
SQLCommand cmd=new SQLCommand("select query to get byte data",con);
byteData = (byte[])cmd.ExecuteDataScalar();
if (byteData != null)
{
if (byteData.Length == 0)
bReturnvalue = false;
else if (byteData.Length > 0)
{
ArraySize = byteData.Length; // Track# 83710
FileStream fs = new FileStream(sDestination, FileMode.Create, FileAccess.Write);
fs.Write(byteData, 0, ArraySize);
fs.Close();
bReturnvalue = true;
}
}
}
catch (Exception ex)
{
throw new Exception(ex);
}

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 7/20/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Refer this link
it will help u
http://www.codeproject.com/Articles/354639/Storing-and-Retrieving-Images-from-SQL-Server-Usin

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response