Function To convert a image or Pdf file to a bite array
Public Shared Function GetBytesFromUrl(ImageFilePath As String) As Byte()
Dim _tempByte As Byte() = Nothing
If String.IsNullOrEmpty(ImageFilePath) = True Then
Throw New ArgumentNullException("Image File Name Cannot be Null or Empty", "ImageFilePath")
Return Nothing
End If
Try
Dim _fileInfo As New System.IO.FileInfo(ImageFilePath)
Dim _NumBytes As Long = _fileInfo.Length
Dim _FStream As New System.IO.FileStream(ImageFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim _BinaryReader As New System.IO.BinaryReader(_FStream)
_tempByte = _BinaryReader.ReadBytes(Convert.ToInt32(_NumBytes))
_fileInfo = Nothing
_NumBytes = 0
_FStream.Close()
_FStream.Dispose()
_BinaryReader.Close()
Return _tempByte
Catch ex As Exception
'#########
Dim objErrHandler As clsErrHandler = New clsErrHandler()
objErrHandler.WriteError(ex)
'#########
Return Nothing
End Try
End Function