Without considering the file extension, i am trying to determine the file type by reading the file contents. Is that possible ?
I`ve observed that every .pdf file has "%PDF-1.3" or "%PDF-1.4" etc as the very first chars. If i try removing them, the file `ll still be a .pdf but can not be opened by the Acrobat Reader. I think that `ll help me determine whether a file is a .pdf.
My actual trouble is in reading a ".doc" file. Is there any way, i can read the bytes from a .doc file and determine whether it is actually a .doc file ? Can we identify other MS - Office files also in this manner ?