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?

+1


source to share


2 answers


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:



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.

+2


source


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.



0


source







All Articles