public RebuildPropertyFile(string path) { try { var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var reader = XmlReader.Create(stream); var file = new PropertyFile(); file.ReadXML(reader); reader.Close(); stream.Close(); stream = new FileStream(path + ".part", FileMode.Create, FileAccess.Write); XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8); writer.Formatting = Formatting.Indented; file.WriteXML(writer); writer.Close(); stream.Close(); } catch (Exception) { failed = true; if (File.Exists(path + ".part")) File.Delete(path + ".part"); return; } File.Replace(path + ".part", path, path + ".backup"); File.Delete(path + ".backup"); }
private void writePropFile(byte[] data, string fn) { PropertyFile file = new PropertyFile(); file.Read(new MemoryStream(data)); stripGeneratedLocaleReferences(file); var output = File.Create(fn + ".xml"); XmlTextWriter writer = new XmlTextWriter(output, Encoding.UTF8); writer.Formatting = Formatting.Indented; file.WriteXML(writer); writer.Flush(); output.Close(); }