' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.IO
Imports System.Text

Class MainClass
    Public Shared Sub Main(ByVal args As String())
        Dim fs As FileStream = New FileStream("C:\z.pdf", FileMode.Open, FileAccess.Read)
        Dim b(3) As Byte
        fs.Read(b, 0, b.Length)
        fs.Close
        Dim hdr As String = Encoding.Default.GetString(b, 0, b.Length)
        Dim pdf As Boolean = hdr.Equals("%PDF")
        Console.WriteLine(pdf)
    End Sub
End Class 
