[Tutor] opening a file directly from memory

Alan Gauld alan.gauld at btinternet.com
Sun Nov 15 10:35:28 CET 2009

<mjekl at iol.pt> wrote
>> You forgot to answer the question.  You say "The OS knows how to  
>> open".  Does *your* *program* know what program is needed, to open  
>> this particular binary data?
> Yes. My program knows. A database column stores the complete file name  
> (including extension), and I can be certain the applications will be  
> available to run the file.

You still haven't answered the question.

We have established that
a) The OS knows what program is associated with the file
b) your program knows the file name and location

But does your program - or more specifically you as the author - know 
what program the OS will use to open the file? If you do you can call it 
explicitly, but if you do not then you need to find a way of getting the 
OS to tell you, or to leave it to the OS.

For example a txt file could be opened by any of hundreds of text 
editors, depending on what the user selected, but a Photoshop 
file will typically only be opened by photoshop.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list