Is there a built-in way to get the standard extension of a given MIME type in Delphi (XE7)?
I'm looking for the easiest and most general way to implement a function that would be called like this:
fileExt := GetExtension('text/xml');
Is there a built-in way to get the standard extension of a given MIME type in Delphi (XE7)?
I'm looking for the easiest and most general way to implement a function that would be called like this:
fileExt := GetExtension('text/xml');
For more current versions of Delphi, you can use the TMimeTypes class in the unit System.Net.Mime
There are two methods which you can use to seed the internal dictionary to perform the lookup. The first AddDefTypes will add the standard types, and the method AddOSTypes will add any defined by the host OS (for windows, it does a registry crawl). If you call TMimeTypes.GetDefault it will construct a TMimeTypes instance using both methods the first time it is called (singleton).