Get Mime Type of File

  • Thread starter Thread starter Shapper
  • Start date Start date
S

Shapper

Hello,

How can I get the Mime Type of a file given its path?

I know how to get the file to a stream.
But I am not able to gets its Mime Type.

Thank You,
Miguel
 
How can I get the Mime Type of a file given its path?

I know how to get the file to a stream.
But I am not able to gets its Mime Type.

Are you making the assumption that the MIME type is somehow stored in the
file itself? Because that's rarely the case.
 
How can I get the Mime Type of a file given its path?

I know how to get the file to a stream.
But I am not able to gets its Mime Type.

If it is a remote file, then you can use HttpWebRequest
to get it and see the MIME type assigned by the server in
HttpWebResponse ContentType.

If it is a local file, then you decide what MIME type
it has.

If it is the opinion of a specific application then you
will need to check that apps config.

Arne
 
If it is a remote file, then you can use HttpWebRequest
to get it and see the MIME type assigned by the server in
HttpWebResponse ContentType.

....and hope the Web server got it right.
 
...and hope the Web server got it right.

It will show what MIME type it is actually being
labeled with.

Whether that is the MIME type it should have been
labeled with is another question.

Arne
 
Back
Top