file type using filecontent
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? Thank开发者_JS百科s
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...).
Before getting files in byte array, get FileExtension, and use ID for your byte and extension to find with index.
精彩评论