-1

I use the FilePicker to let the user select a file. I want to determine the type of the file so I can show different visuals. How can I see what's in the file?

JDiek
  • 91
  • 1
  • 5
  • 1
    Hello, and welcome to StackOverflow. Please review how to ask good questions on stackoverflow http://www.stackoverflow.com/help/how-to-ask – DotNetRussell Jun 29 '16 at 17:56

1 Answers1

0

The easiest way is probably to look at the ContentType property of a file. The ContentType contains the MIME type of the file. So this can be "audio/mpeg". You can also look at the first part if you want to do the same for all images or videos for instance.

You can use StartsWith() method for this. E.g.:

item.IsVideo = file.ContentType.StartsWith("video/");

You can find lists of well known mime types on the internet. This is a good example: http://webdesign.about.com/od/multimedia/a/mime-types-by-file-extension.htm

Martin Tirion
  • 1,246
  • 1
  • 7
  • 10