Hi Folks,
I know I haven't yet put in the error checking functions, but apart from that do you see any method to improve this code?

Cheers,
Abhijit
VB Code:
  1. Function CheckForJpegs(ByVal sFile As String) As Boolean
  2.         'Author     -   Abhijit
  3.         'Date       -   19-July-2005
  4.         'Purpose    -   Check if the given image file is a jpeg file or not.
  5.         'Assumption -   The image file exists in the given location.
  6.         Dim strFileStream As FileStream
  7.         Dim binRead As BinaryReader
  8.         Dim iByteCounter As Integer
  9.         Dim strTemp As String
  10.         iByteCounter = 0
  11.  
  12.         strFileStream = New FileStream(sFile, FileMode.Open)
  13.         binRead = New BinaryReader(strFileStream)
  14.         Dim fileByte() As Byte = binRead.ReadBytes(11)
  15.             strFileStream.Close()
  16.         For iByteCounter = 0 To 5
  17.             strTemp = strTemp & Hex((fileByte(iByteCounter)))
  18.         Next iByteCounter
  19.  
  20.         For iByteCounter = 6 To 10
  21.             strTemp = strTemp & ChrW((fileByte(iByteCounter)))
  22.         Next iByteCounter
  23.  
  24.  
  25.  
  26.         If InStr(strTemp, "JFIF", CompareMethod.Text) Then
  27.             CheckForJpegs = True
  28.         ElseIf strTemp.Substring(0, 5) = "FFD8FF" Then 'This test is required for files created on Mac / older versions on PC
  29.             CheckForJpegs = True
  30.         Else
  31.             CheckForJpegs = False
  32.         End If
  33.     End Function