// 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) using System; using System.IO; using System.Text; class MainClass { public static void Main(string[] args) { FileStream fs = new FileStream(@"C:\z.pdf", FileMode.Open, FileAccess.Read); byte[] b = new byte[4]; fs.Read(b, 0, b.Length); fs.Close(); String hdr = Encoding.Default.GetString(b, 0, b.Length); bool pdf = (hdr == "%PDF"); Console.WriteLine(pdf); } }