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");
        }
Exemple #2
0
        void writePropFile(string groupName, string instanceName, string inputFileName, Stream output, out byte[] locale)
        {
            // Convert .prop.xml to binary .prop file and write it to output
            var reader = XmlReader.Create(File.OpenText(inputFileName));
            var file   = new PropertyFile();

            file.ReadXML(reader);
            reader.Close();
            locale = generateLocale(file, groupName, instanceName);
            file.Write(output);
        }