Pages

Wednesday, January 16, 2013

How to get MIME type of file in C#



There is no direct way to get MIME type of file in C#, I have tried couple of options but didn't get any luck. though there are some WIN 32 registry and InteropServices classes from where we can get MIME type but I feel it’s too much code for getting MIME type. instead of using these classes I have found static solutions for getting MIME type, it's switch-case code for all the available MIME type based on the file extension (I know solution is not GOOD with all static file extension and MIME type)

Reference Links:



Link for list of common MIME types and their corresponding file extensions: http://www.webmaster-toolkit.com/mime-types.shtml

If anyone find any better solution then Please share here ;)

No comments:

Post a Comment