tags:

views:

27

answers:

2

Hi, I have filecontent in a byte array, and how to find the type of this file from this byte array content? Like .doc, .docx, .jpg? Thanks

A: 

Before getting files in byte array, get FileExtension, and use ID for your byte and extension to find with index.

Serkan Hekimoglu
+2  A: 

There is no general answer. Most file formats can be recognized by looking at the content, analysing the header. However, there is no 'standard' header, and many formats have no header at all (think CSV for example).

If the content comes from a file on disk, create a FileInfo and query its extension.

If you only have the content, you'll have to build you own analysers that look at headers and/or guess based on other facts (e.g. text with a lot of commas...).

Mau