static void trySave(DtoContainer usb) { try { using (var z = new IsolatedStorageFileStream(_isoName, FileMode.Create, GetIsolatedStorageFile())) { using (var streamWriter = new StreamWriter(z)) { new XmlSerializer(usb.GetType()).Serialize(streamWriter, usb); streamWriter.Close(); } } } catch (Exception ex) { ex.Log(); } //Jul2015: Back-up storage to normal store has been removed for code scan requirement: //try { using (var z = new FileStream(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), _isoName), FileMode.OpenOrCreate)) { using (var streamWriter = new StreamWriter(z)) { new XmlSerializer(usb.GetType()).Serialize(streamWriter, usb); streamWriter.Close ( ); } } } catch (Exception ex) { ex.Log(); } }
public static void TestIsoAccessibilty(string msg) { try { var save = new DtoContainer { Msg = msg, Time = DateTime.Now }; trySave(save); var read = tryLoad(); var rr = GetIsolatedStorageFile().GetDirectoryNames(); Trace.WriteLine(save.Time == read.Time ? "AP: SUCCESS - Iso Storage is fine." : "AP: Iso Storage is not accessible!!!"); } catch (Exception ex) { ex.Log(); } }