开发者

NET library for file/mime type detection

开发者 https://www.devze.com 2023-02-07 21:20 出处:网络
I need a file type identification NET library (best 100% managed) with a similar functionality to TrIDEngine. I would ultimately need to pass a Stream representing content and expect the return value

I need a file type identification NET library (best 100% managed) with a similar functionality to TrIDEngine. I would ultimately need to pass a Stream representing content and expect the return value as either a MIME type or some enum/string easily mapped to a MIME type.

I want to detect just a handful of media types like WMV, WAV, MP3 and common image formats like JPEG, PNG, GIF and BMP.

The problem with TrIDEngine is the fact that it appears to only come in a form of a command line utility and expects a physical 开发者_高级运维file path, not the required Stream.


If you just need to detect a few file types you could lookup the format on Wikipedia and check for the header or "magic" bytes yourself. You can usually identify a file type from the first few bytes, so you can read a few bytes from the stream and check them yourself. Not exactly what you're asking for, but it shouldn't be too hard for only a few types.

0

精彩评论

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