Get Mime Type of File

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
 
J

Jeff Johnson

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.
 
A

Arne Vajhøj

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
 
J

Jeff Johnson

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.
 
A

Arne Vajhøj

...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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top