Storage Options in Silverlight
I'm currently working on a project that has a very interesting set of requirements. It must be in silverlight but all data stored MUST be stored locally and cannot be sent to a server but it .
Isolated storage seemed to be the perfect candidate for this except a number of clients wanted the ability to choose where the data file should be stored (which isolated storage seems to abstract from you) and it appears that I am unable to open a file save dialog in silverlight unless its "user initiated"
So, instead of popping up a save dialog ever time the user saves anything in the application what are my options?
Things I've been brainstorming: Open the file when the app starts and hold the stream open for the duration of the app, have them setup a roaming profile so app data and isolated stor开发者_运维技巧age is stored on their thumb drive (really messy solution). Is there anything else? Maybe pushing the data to the browser and using some crafty javascript solution?
I don't think there is a direct solution to this problem. Any access to a local file without user interaction sounds like a security hole in the platform (Silverlight and/or the browser).
If you to want code yourself up a security hole, I can think of one solution. ActiveX controls could solve this, but then you're limited to IE. I suppose browser add-ins could do this as well.
I could also imagine sending the data to a web service and that service somehow pushing (but not storing) the files onto the local machine via some type of network share or something (intranet only). But that sounds awful!
A sane compromise would be to just force users to interactively open a file in silverlight. Make it optional, using isolated storage if they chose not to open a file with the dialog. Maybe make it easy to switch between the two options.
What if you used isolated storage to save the location of the save file, and then simply ask for a save location on first run, or if the save file is not in its saved location. That was the data is stored locally with some sort of control, but you're not keeping the stream open (potentially for hours) or prompting the user for every save.
精彩评论