示例#1
0
文件: Output.cs 项目: 2dave/Data
        /// <summary>
        /// Loads an output from a path on disk.
        /// </summary>
        /// <param name="path">Path to output file saved on disk.</param>
        /// <param name="suppressVersionCheck">Suppresses wix.dll version mismatch check.</param>
        /// <returns>Output object.</returns>
        public static Output Load(string path, bool suppressVersionCheck)
        {
            using (FileStream stream = File.OpenRead(path))
                using (FileStructure fs = FileStructure.Read(stream))
                {
                    if (FileFormat.Wixout != fs.FileFormat)
                    {
                        throw new WixUnexpectedFileFormatException(path, FileFormat.Wixout, fs.FileFormat);
                    }

                    Uri uri = new Uri(Path.GetFullPath(path));
                    using (XmlReader reader = XmlReader.Create(fs.GetDataStream(), null, uri.AbsoluteUri))
                    {
                        try
                        {
                            reader.MoveToContent();
                            return(Output.Read(reader, suppressVersionCheck));
                        }
                        catch (XmlException xe)
                        {
                            throw new WixCorruptFileException(path, fs.FileFormat, xe);
                        }
                    }
                }
        }
示例#2
0
文件: Output.cs 项目: 2dave/Data
        /// <summary>
        /// Saves an output to a path on disk.
        /// </summary>
        /// <param name="path">Path to save output file to on disk.</param>
        public void Save(string path)
        {
            Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path)));

            using (FileStream stream = File.Create(path))
                using (FileStructure fs = FileStructure.Create(stream, FileFormat.Wixout, null))
                    using (XmlWriter writer = XmlWriter.Create(fs.GetDataStream()))
                    {
                        writer.WriteStartDocument();
                        this.Write(writer);
                        writer.WriteEndDocument();
                    }
        }