I am trying to open a file with a Unicode file name for binary access to calculate the MD5 check sum. I have the file names and path stored in a excel sheet correctly.
The code then fails atOpen sPath For Binary Access Read As lngFileNumber
with 'Run-Time error'52': Bad file name or number
Function GetFileBytes(ByVal sPath As String) As Byte()
' makes byte array from file
Dim lngFileNum As Long, bytRtnVal() As Byte, bTest
lngFileNum = FreeFile
If LenB(Dir(sPath)) Then ''// Does file exist?
Open sPath For Binary Access Read As lngFileNum
'a zero length file content will give error 9 here
ReDim bytRtnVal(0 To LOF(lngFileNum) - 1&) As Byte
Get lngFileNum, , bytRtnVal
Close lngFileNum
Else
Err.Raise 53 'File not found
End If
GetFileBytes = bytRtnVal
Erase bytRtnVal
End Function
Any suggestions?