I have files saved in my Oracle database with field BFile
. I do a select
and I get that field BFile
. But now I have doubts about how to get that byte array, recover the stored file and save it in C:\
.
These are my advances:
OracleCommand command = new OracleCommand("SELECT IMG FROM IMAGES WHERE ID='" + idText + "'", conn2);
OracleDataReader reader = command.ExecuteReader();
using (reader)
{
if (reader.Read())
{
OracleBFile bFile = reader.GetOracleBFile(0);
byte[] buffer = new byte[bFile.Length];
using (bFile)
{
bFile.Seek(0, SeekOrigin.Begin);
bFile.Write(buffer, 0, 100);
}
}
else
{
MessageBox.Show("Error");
}
}