Reputation: 508
I'm making a Windows Universal App in c#. I get a MIME type from my server and I have to save a file with the extension that that MIME type represents. How can I convert this MIME type to a file extension in a way that works with Windows Universal Apps, so with both Windows Phone 8.1 and Windows 8.1?
I don't mind a:
#if Windows_Phone
{code}
#elif
{code}
#endif
Construction.
Upvotes: 0
Views: 592
Reputation: 1402
You don't have access to the Registry or any similar Windows magic, neither in W8 nor in WP8. There's only one exception I know of: Windows.Graphics.Imaging.BitmapDecoder.GetDecoderInformationEnumerator()
tells you both about mimetypes and extensions, but only of image formats installed on the local machine.
You'll probably need to manually create a dictionary which maps from mimetype to extension. Be warned: this is a neverending task. E.g. the mimetype "audio/x-mpegurl" has two extensions: .m3u and .m3u8. At the same time many servers claim that .m3u files have the mimetype "audio/m3u". So you'll end up tweaking and updating this dictionary over and over ...
Upvotes: 1
Reputation: 3714
I'm afraid there is no platform API available for this. You will need to create your own mapping.
Upvotes: 1