I've got the following function that when it opens a file to establish the file type doesn't return the correct value. What am I doing wrong?
The first 8 characters are in this format %PDF-1.4
Function GetFileType(xFile As String) As Boolean
Dim fileBytes As Byte()
fileBytes = System.IO.File.ReadAllBytes(xFile)
Dim s As String
s = System.Text.Encoding.UTF8.GetString(fileBytes)
Select Case s
Case s.Substring(1, 3) = "PDF"
GetFileType = False
Case Else
GetFileType = True
End Select
End Function
It doesn't match the case statement, it's always moves to the else part which has me stumped.