Reputation: 1135
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
Upvotes: 1
Views: 552
Reputation: 14468
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...).
Upvotes: 2
Reputation: 4284
Before getting files in byte array, get FileExtension, and use ID for your byte and extension to find with index.
Upvotes: 0