public void load() { String fileName = Constants.CFG_FILE_NAME; try { using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFileStream storageFileStream = new IsolatedStorageFileStream(fileName, System.IO.FileMode.OpenOrCreate, storageFile)) { intLoadStream(storageFileStream); } } catch { _cfg = new StoredConfig(); } }
public void intLoadStream(Stream stream) { _cfg = null; if (stream.Length > 0) { try { DataContractSerializer serializer = new DataContractSerializer(typeof(StoredConfig)); _cfg = serializer.ReadObject(stream) as StoredConfig; } catch { _cfg = null; } } if (_cfg == null) { _cfg = new StoredConfig(); } }