Backing Up the Local Database

To transfer the local database to the server, it must first be copied to a directory in isolated storage. This prevents the file from being modified by the SQL CE engine while the transfer is under way. The viewmodel’s BackupDatabase method creates a temporary directory and then copies the local .sdf database file to the directory, as shown:

string uploadUrl = "http://localhost:60182/BackupService/UploadFile/";const string localDatabaseName = "Todo.sdf";const string transferDirectory = "/shared/transfers";string uploadPath = transferDirectory + "/" + localDatabaseName;using (IsolatedStorageFile isolatedStorageFile            = IsolatedStorageFile.GetUserStoreForApplication()){    if ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.