Question

I have an XBAP app, which shows some pictures, and my users would like to save some of them to disk. But my XBAP app runs in the partial trust mode, so it can't initiate SaveFileDialog, not to mention it can't access the File System.

What's would be the Stack Overflow recommended way to save a pic to disk in this case?

Was it helpful?

Solution

I found a solution to my problem and I'm going to put this answer as a community wiki.

As expected, I wasn't able to access file system, show SaveFileDialog or save the image to the clipboard due to the partial-trust security limitations.

So, I've created an .ashx handler on the site, from which my XBAP application is deployed, which receives a certain image id in the URL string, queries the image from the DB, and returns the image (context.WriteBinary) under the proper content header "image/jpeg".

In my XBAP, instead of the Image control I've put the WebBrowser control, provided with the proper URI (you might need a trick to bind the Source property). You can only specify an URI that is pointing to the site of origin of your XBAP app. It can be an absolute path, or it can use the special syntax including pack://siteoforigin:,,

Voila, now the picture supports the standard browser context menu with "Save...", "Set as background" and all the other useful elements :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top