|
Revision as of 02:35, 12 May 2012This function uses simple VBA IO to load a binary file into a byte array. Add error handling and file path validation as you wish. CODE ' FileToByteArray ' http://www.utteraccess.com/wiki/index.php/FileToByteArray ' Code courtesy of UtterAccess Wiki ' Licensed under Creative Commons License ' http://creativecommons.org/licenses/by-sa/3.0/ ' ' You are free to use this code in any application, ' provided this notice is left unchanged. ' ' rev date brief descripton ' 1.0 2012-05-11 ' Public Function FileToByteArray(FilePath As String) As Byte() 'add error handling as required 'add path validation as required Dim FileNum As Integer Dim Ret() As Byte FileNum = FreeFile Open FilePath For Binary Access Read As #FileNum ReDim Ret(LOF(FileNum) - 1) As Byte Get FileNum, , Ret Close #FileNum FileToByteArray = Ret End Function
|
| Disclaimers |