开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜