I am in a Windows Desktop application and I have a data stream and a mime type in the database. Is there a better way than writing it to a temp folder and launching the default editor for it?
If I have to use the temp folder how can I get the file extension from the MIME type in a C# Windows Desktop application?
-
It depends on what you want to do with that data stream. If all you want to do is open the default program for that file type, writing a temp file and calling Process.Start on it isn't a bad way to go. If you're looking to perform other operations on the data... well, it depends what operations you had in mind.
Jamey McElveen : I just want the default editorJamey McElveen : However, it would be better if I did not have to save it and invoke a file watcher. -
Lookup the MIME type in
HKEY_CLASSES_ROOT\MIME\Database\Content Typeto find out the corresponding file extension and go from there. Some starter links:- http://msdn.microsoft.com/en-us/library/ms775147(VS.85).aspx
- http://bitworking.org/news/Atom_Auto_Sub_How_To
If that is not enough, maybe libmagic (used by the
filecommand line tool) or its database can be of use to you, even though it is quite UNIX:y.
0 comments:
Post a Comment