/// <summary> /// Deserializes object from isolated storage file. /// </summary> /// <typeparam name="T">Type of object.</typeparam> /// <param name="fileName">Path to isolated storage file.</param> /// <returns></returns> public static T Deserialize <T>(string subDirectory, string fileName) { try { // Open isolated storage. using (var storageManager = new IsolatedStorageManager()) { fileName = Prepare(storageManager, subDirectory, fileName); if (storageManager.FileExists(fileName)) { // Open file from storage. using (var stream = storageManager.OpenFile(fileName, IO.OpenFileMode.Open)) { XFile file = XFile.LoadBinary(stream, fileName); var serializer = new XSerializer(file); return(serializer.Deserialize <T>("Data")); } } } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } return(default(T)); }
public static bool FileExist(string path) { using (var storageManager = new IsolatedStorageManager()) { return(storageManager.FileExists(path)); } }