Exemple #1
0
        /// <summary>
        /// Processes a .reg file to the writer. This will copy the input file into a
        /// temp directory and add empty lines before each key declaration. That
        /// processed file is what gets used as input to the WiX translation code.
        /// </summary>
        /// <param name="writer">Writer to output to.</param>
        /// <param name="path">Path to registry file.</param>
        public static void ProcessRegistryFile(XmlWriter writer, string path)
        {
            FileInfo file = new FileInfo(path);

            if (!file.Exists)
            {
                throw new WixFileNotFoundException(path, "File");
            }

            TempFileCollection tempFiles = new TempFileCollection();

            StreamReader reader   = new StreamReader(path);
            FileInfo     tempFile = new FileInfo(Path.Combine(tempFiles.BasePath, file.Name));

            tempFile.Directory.Create();
            StreamWriter tempWriter = new StreamWriter(Path.Combine(tempFiles.BasePath, file.Name));

            string line;

            while (null != (line = reader.ReadLine()))
            {
                if (line.StartsWith("["))
                {
                    tempWriter.WriteLine();
                    tempWriter.WriteLine(line);
                }
                else
                {
                    tempWriter.WriteLine(line);
                }
            }
            tempWriter.Close();
            reader.Close();

            TallowRegProcessing regProc = new TallowRegProcessing();

            regProc.ConvertRegFile(tempFile, writer);
        }
Exemple #2
0
        /// <summary>
        /// Processes a .reg file to the writer. This will copy the input file into a
        /// temp directory and add empty lines before each key declaration. That
        /// processed file is what gets used as input to the WiX translation code.
        /// </summary>
        /// <param name="writer">Writer to output to.</param>
        /// <param name="path">Path to registry file.</param>
        public static void ProcessRegistryFile(XmlWriter writer, string path)
        {
            FileInfo file = new FileInfo(path);
            if (!file.Exists)
            {
                throw new WixFileNotFoundException(path, "File");
            }

            TempFileCollection tempFiles = new TempFileCollection();

            StreamReader reader = new StreamReader(path);
            FileInfo tempFile = new FileInfo(Path.Combine(tempFiles.BasePath, file.Name));
            tempFile.Directory.Create();
            StreamWriter tempWriter = new StreamWriter(Path.Combine(tempFiles.BasePath, file.Name));

            string line;
            while (null != (line = reader.ReadLine()))
            {
                if (line.StartsWith("["))
                {
                    tempWriter.WriteLine();
                    tempWriter.WriteLine(line);
                }
                else
                {
                    tempWriter.WriteLine(line);
                }
            }
            tempWriter.Close();
            reader.Close();

            TallowRegProcessing regProc = new TallowRegProcessing();
            regProc.ConvertRegFile(tempFile, writer);
        }