string show = "select NOTES_FILE from sample_file where FILE_ID=1";
con.Open(); // this is database connection
FileStream showFile;
BinaryWriter bw;
int buffsize = 100;
byte[] output = new byte[buffsize];
long retval;
long startindex;
OracleCommand cmd2 = new OracleCommand(show, con);
OracleDataReader dr = cmd2.ExecuteReader(CommandBehavior.SequentialAccess);
string savedimage="c:/vyas.jpg";
while (dr.Read())
{
showFile = new FileStream(savedimage, FileMode.Create);
bw = new BinaryWriter(showFile);
startindex = 0;
retval = dr.GetBytes(0, startindex, output, 0, buffsize);
while (retval == buffsize)
{
bw.Write(output);
bw.Flush();
startindex += buffsize;
retval = dr.GetBytes(0, startindex, output, 0, buffsize);
}
bw.Write(output,0,(int)retval-1);
bw.Flush();
bw.Close();
showFile.Close();
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment