The Photo app (like Viewer) requires a path to the photo to read the file and preview it. Since your photo comes from a database, Viewer app (or any other photo app) is unlikely to get access to it.
One solution to this will be to create a temporary file with a
Guid
based name. This will allow you to store the file for a while and then pass that temporary file to the Photo viewer. This is the only way you can solve it — as I believe photo viewers won't access database streams. :laugh:
You would need to write all the content from the database (binary content) to a file with the proper mime types and then store that as a temporary file in your local directories to provided the viewer with the access to this file.
Create a temporary file from stream object in c# - Stack Overflow[
^], you can later on delete it when no longer needed. :-)
Opening the photo viewer will be just simple task, you can use the
Process
type from
System.Diagnostics
and start a new process to show the file.
Process.Start("viewer.exe", "parameter-temp-file-path");
As for the "when no longer needed" part, you can check when the process terminates, and then delete the file.
For more on the Process class, read:
Process Class (System.Diagnostics)[
^]