quarta-feira, 9 de janeiro de 2008

ReadBinary()

Lê um arquivo no modo binário.
O FileName pode ser um caminho absoluto ou relativo.

Function ReadBinary(ByVal FileName)

On Error Resume Next

If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
If Err Then Err.Clear

On Error GoTo 0

Dim Strm
Set Strm = Server.CreateObject("Adodb.Stream")
Strm.Type = 1 'Binary
Strm.Open

On Error Resume Next

Strm.LoadFromFile FileName

If Err Then
Err.Clear
Set Strm = Nothing
ReadBinary = Null
On Error GoTo 0
Exit Function
End If

On Error GoTo 0

ReadBinary = Strm.Read
Strm.Close
Set Strm = Nothing

End Function

Nenhum comentário: