Hey ALL
this is my code.
the problem is that i get the file on the HDD with the exact size as the original file which was stored in the DB but the file is empty.There is no image in the file.Can someone please help me out here..........
OracleDataReader myReader = CMD.ExecuteReader(CommandBehavior.SequentialAccess );
string FilePath="c:\\Pictures\\";
while (myReader.Read())
{
// Create a file to hold the output.
fs = new FileStream(FilePath+"ACCUSED.bmp", FileMode.OpenOrCreate, FileAccess.Write);
bw = new BinaryWriter(fs);
// Reset the starting byte for the new BLOB.
startIndex = 0;
// Read the bytes into outbyte[] and retain the number of bytes returned.
retval = myReader.GetBytes(0, startIndex, outbyte, 0,bufferSize);
// Continue reading and writing while there are bytes beyond the size of the buffer.
while (retval == bufferSize)
{
bw.Write(outbyte);
bw.Flush();
// Reposition the start index to the end of the last buffer and fill the buffer.
startIndex += bufferSize;
retval = myReader.GetBytes(0, startIndex, outbyte, 0, bufferSize);
}
// Write the remaining buffer.
bw.Write(outbyte, 0, (int)retval );
bw.Flush();
// Close the output file.
bw.Close();
fs.Close();