What is the best way to open / edit data stream if I have a MIME type
I am using Windows Desktop app and I have data stream and mime type in database. Is there a better way than writing it to a temp folder and launching the default editor for it?
If I need to use a temp folder, how can I get the file extension from the MIME type in a C # Windows Desktop application?
source to share
Search for the MIME type in HKEY_CLASSES_ROOT\MIME\Database\Content Type
to find out the corresponding file extension and navigate from there. Some starting links:
- http://msdn.microsoft.com/en-us/library/ms775147(VS.85).aspx
- http://bitworking.org/news/Atom_Auto_Sub_How_To
If that's not enough, maybe libmagic (used by the command line tool file
), or its database could be use for you, although it's pretty UNIX: y.
source to share
It depends on what you want to do with this data stream. If all you want to do is open the default program for that file type, write a temporary file and call Process.Start, that's not a bad way to go. If you want to perform other operations on the data ... well, that depends on what operations you had in mind.
source to share