private void get_bfile(OracleConnection con) { // this helper gets the bfile from the database // table, displays the property values and // writes the content of the file to the console string sqlText = "select file_loc from bfile_test"; // the command object OracleCommand cmd = new OracleCommand(sqlText, con); // get a data reader for the command object OracleDataReader dataReader = cmd.ExecuteReader(); OracleBFile bfile = null; if (dataReader.Read()) { // use the typed accessor to get the bfile bfile = dataReader.GetOracleBFile(0); } // open the file // try // { // bfile.OpenFile(); // } // catch(OracleException ex) // { // Console.WriteLine(ex.ToString()); // } // display the property values Console.WriteLine("Retrieved bfile from database..."); Console.WriteLine(" CanRead = " + bfile.CanRead.ToString()); Console.WriteLine(" CanSeek = " + bfile.CanSeek.ToString()); Console.WriteLine(" CanWrite = " + bfile.CanWrite.ToString()); Console.WriteLine(" Connection = " + bfile.Connection.ConnectionString); Console.WriteLine(" DirectoryName = " + bfile.DirectoryName.ToString()); Console.WriteLine(" FileExists = " + bfile.FileExists.ToString()); Console.WriteLine(" FileName = " + bfile.FileName.ToString()); Console.WriteLine(" Length = " + bfile.Length.ToString()); Console.WriteLine(" Position = " + bfile.Position.ToString()); Console.WriteLine(" Value = " + bfile.Value.ToString()); // convert the byte array to a string UTF7Encoding utf = new UTF7Encoding(); byte[] bf = new byte[bfile.Length]; bfile.Read(bf, 0, Convert.ToInt16(bfile.Length)); bfile.Close(); Console.WriteLine(" Value = \n" + utf.GetString(bf)); }