Wednesday, 14 April 2010

WP7 IsolatedStorage Backup/Restore

One of the drawbacks of the WP7 Emulator is that it doesn't save the state between sessions and also it is difficult to deploy a file with your project and then use it. This means that every time you start a new session of the emulator you loose all the data on the IsolatedStorage.
I've developed a small solution (there is room for improvement) for backing-up and restoring the files (folder structure included) of the IsolatedStorage. It is using an WCF service that stores/sends file content from/to the IsolatedStorage in/from a folder named Backup located in the WCF project folder. For optimizing the communication the service uses binaryMessageEncoding. It also splits the files in 100Kbytes parts (you can modify this size from the source code if you want bigger parts- it will be faster) .
The solution is easy to use even if it took me a lot of time to make it work (especially the readerQuotas, maxBufferSize, maxStringContentLength). In fact I was having "fun" with it at 3 o'clock in the morning. If you want to backup your IsolatedStorage just hit backup and it will write the content of IsolateStorage in the Backup folder of the pc. If you want to restore/copy files to the IsolatedStorage copy the files/folders you want to the Backup folder of the PC and then hit Restore and it will copy all the data to the IsolatedStorage.

Hope you'll like it! Don't forget to modify the ServiceReferences.ClientConfig before you run the project



























As usual you can download the Source code

0 comments:

Post a Comment