@@ -68,7 +68,7 @@ internal static bool IsBFileColumn(OracleDataReader reader, string columnName)
6868 /// <param name="reader">The Oracle data reader containing the BFILE column.</param>
6969 /// <param name="columnIndex">The index of the BFILE column to read.</param>
7070 /// <returns>Returns the BFILE content as a Base64-encoded string, or an empty string if the BFILE is null.</returns>
71- internal static string GetBFileContent ( OracleDataReader reader , int columnIndex )
71+ internal static string GetBFileBase64Content ( OracleDataReader reader , int columnIndex )
7272 {
7373 string content = string . Empty ;
7474 var bFile = reader . GetOracleBFile ( columnIndex ) ;
@@ -96,7 +96,7 @@ internal static string GetBFileContent(OracleDataReader reader, int columnIndex)
9696 /// <param name="reader">The Oracle data reader containing the BFILE column.</param>
9797 /// <param name="columnName">The name of the BFILE column to read.</param>
9898 /// <returns>Returns the BFILE content as a Base64-encoded string, or an empty string if the BFILE is null or the column does not exist.</returns>
99- internal static string GetBFileContent ( OracleDataReader reader , string columnName )
99+ internal static string GetBFileBase64Content ( OracleDataReader reader , string columnName )
100100 {
101101 string content = string . Empty ;
102102 try
@@ -126,5 +126,40 @@ internal static string GetBFileContent(OracleDataReader reader, string columnNam
126126 return content ;
127127 }
128128
129+ /// <summary>
130+ /// Retrieves the content of a BFILE column from an Oracle data reader as a byte array, using the column name.
131+ /// </summary>
132+ /// <param name="reader">The Oracle data reader containing the BFILE column.</param>
133+ /// <param name="columnName">The name of the BFILE column to read.</param>
134+ /// <returns>Returns the BFILE content as a byte array, or <c>null</c> if the BFILE is null or the column does not exist.</returns>
135+ internal static byte [ ] GetBFileByteContent ( OracleDataReader reader , string columnName )
136+ {
137+ byte [ ] buffer = null ;
138+ try
139+ {
140+ int columnIndex = reader . GetOrdinal ( columnName ) ;
141+ var bFile = reader . GetOracleBFile ( columnIndex ) ;
142+ if ( bFile != null && ! reader . IsDBNull ( columnIndex ) )
143+ {
144+ bFile . OpenFile ( ) ;
145+ buffer = new byte [ bFile . Length ] ;
146+ int bytesReadTotal = 0 ;
147+ while ( bytesReadTotal < buffer . Length )
148+ {
149+ int bytesRead = bFile . Read ( buffer , bytesReadTotal , buffer . Length - bytesReadTotal ) ;
150+ if ( bytesRead == 0 )
151+ break ;
152+ bytesReadTotal += bytesRead ;
153+ }
154+ bFile . Close ( ) ;
155+ }
156+ }
157+ catch ( IndexOutOfRangeException )
158+ {
159+ return buffer ;
160+ }
161+ return buffer ;
162+ }
163+
129164 }
130165}
0 commit comments