PowerBuilder Function Read File To Blob gf_convert_file_to_blob
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | // Function Name : gf_convert_file_to_blob // Return Type : Blob Integer li_FileNo Integer li_Reads Integer li_i Integer li_value Long ll_FileLen Blob lblb_temp String ls_docname String ls_named li_value = GetFileOpenName("Select File", ls_docname, ls_named, " ", "All Files (*.*), *.*") If li_value <> 1 Then Return li_FileNo = FileOpen(ls_docname, StreamMode!, Read!) If li_FileNo < 0 Then Return ll_FileLen = FileLength(ls_docname) //////////////////////////////////////////////////////////////////////////////////////// // //Determine the number of reads required to read the entire file ////////////////////////////////////////////////////////////////////////////////////////// If ll_FileLen > 32765 Then If Mod(ll_FileLen, 32765) = 0 Then li_Reads = ll_FileLen / 32765 Else li_Reads = (ll_FileLen / 32765) + 1 End If Else li_Reads = 1 End If For li_i = 1 To li_Reads If FileRead(li_FileNo, lblb_temp) = -1 Then Return ablb_data = ablb_data + lblb_temp Next FileClose(li_FileNo) Return ablb_data |
Good Luck!