private void TestXml2() { GamePadInput pad = GamePadInput.GetGamePad0(); if (pad.ButtonY.WasPressed) { doTest = 0; } if (doTest >= 0) { if (!Storage4.FileExists(BokuGame.Settings.MediaPath + @"Xml\OptionsData.Xml")) { doTest = 0; /// This breakpoint isn't ever hit, OptionsData.xml exists here } Stream hoseStream = Storage4.OpenWrite(@"Xml\Hoser.xml"); XmlHose hoser = new XmlHose(); hoser.hoser = true; XmlSerializer serializer = new XmlSerializer(typeof(XmlHose)); serializer.Serialize(hoseStream, hoser); Storage4.Close(hoseStream); if (!Storage4.FileExists(BokuGame.Settings.MediaPath + @"Xml\OptionsData.Xml")) { doTest = 0; /// THis breakpoint is hit on failure, after the flush /// OptionsData.xml is not longer there. } ++testsDone; } }
private void TestStorage() { GamePadInput pad = GamePadInput.GetGamePad0(); if (pad.ButtonY.WasPressed) { doTest = 0; } if (doTest >= 0) { string fileName = "Test0.dat"; if (!Storage4.FileExists(fileName)) { doTest = 0; } Stream writeStream = Storage4.OpenWrite(fileName); if (writeStream == null) { doTest = 0; } byte[] writeBytes = new byte[10000]; writeStream.Write(writeBytes, 0, writeBytes.Length); Storage4.Close(writeStream); if (!Storage4.FileExists(fileName)) { doTest = 0; } ++testsDone; } }
public void Serialize(string filepath) { string pathName = MapFolder + filepath; XmlSerializer serializer = new XmlSerializer(typeof(CommandMap)); Stream stream = Storage4.OpenWrite(pathName); serializer.Serialize(stream, this); Storage4.Close(stream); }
public void Save() { XmlSerializer xml = new XmlSerializer(typeof(SiteOptions)); Stream stream = Storage4.OpenWrite(MyFilename); xml.Serialize(stream, this); stream.Close(); }
public void Save() { XmlSerializer xml = new XmlSerializer(typeof(SiteID)); Stream stream = Storage4.OpenWrite(MyFilename); if (stream != null) { xml.Serialize(stream, this); stream.Close(); } }
} // end of HeightMap c'tor /// <summary> /// Writes the current height map to a file. /// </summary> /// <param name="filename"></param> public void Save(string filename) { Stream fs = Storage4.OpenWrite(filename); BinaryWriter bw = new BinaryWriter(fs); Save(bw); #if NETFX_CORE bw.Flush(); bw.Dispose(); #else bw.Close(); #endif Storage4.Close(fs); } // end of HeightMap Save()
public static void UnloadContent() { if (instance == null) { return; } #if DEBUG try { Stream stream = Storage4.OpenWrite(LocalizationResourceManager.HelpResource.Name); XmlSerializer serializer = new XmlSerializer(typeof(Help)); serializer.Serialize(stream, instance); Storage4.Close(stream); } catch { } #endif }
} // end of Load() private static void Save() { Stream stream = null; try { string xmlFileName = FileName(); XmlSerializer serializer = new XmlSerializer(typeof(XmlOptionsData)); stream = Storage4.OpenWrite(xmlFileName); serializer.Serialize(stream, _instance); } catch (Exception e) { Debug.WriteLine(e.Message); } if (stream != null) { Storage4.Close(stream); } } // end of Save()