Get file type/format without the file extension


May 24, 2016
Programming Experience
I am looking to get the file type of a file without its extension. I have found some links noted below, but I when I use the code, it seems to always return ?application/octet-stream?. I have tested Word 2007 documents and other file formats with no success.

Just a bit of background, we store supporting documents in the DB and I would like to know what file format they are. We do have the extension saved but sometimes it is the incorrect extension for that file.

Some links that I have found:

I?ve tried all of the examples from the link below but with no luck.

Maybe I am doing something wrong, any help would be much appreciated.

Using VS 2010, Windows 7, Oracle 11 DB.

Typically you'd just use the file extension to know what type of file it is, however without using the file extension there's ways to find out what type of file it is by checking what encoding the file has (whether it's ascii, unicode, binary; and of the text types is it xml, delimited, plain text, etc) but from your post you're talking more about the file's mime type, which is where you're seeing values like "application/octet-stream" and here's a link on getting file mime types: c# - Get MIME type from filename extension - Stack Overflow
Top Bottom