bool UpdateOpenFileWithRootDirectoryChanges(WixDocument wixDocument, TextAreaControl textAreaControl)
        {
            // Get the xml for the root directory.
            WixDirectoryElement rootDirectory = wixDocument.RootDirectory;
            string xml = GetWixXml(rootDirectory);

            // Find the root directory location.
            bool updated = ReplaceElement(rootDirectory.Id, WixDirectoryElement.DirectoryElementName, textAreaControl, xml);

            if (updated)
            {
                return(true);
            }

            // Find the product end element location.
            IDocument document = textAreaControl.Document;
            Location  location = WixDocument.GetEndElementLocation(new StringReader(document.TextContent), "Product", wixDocument.Product.GetAttribute("Id"));

            if (!location.IsEmpty)
            {
                // Insert the xml with an extra new line at the end.
                ITextEditorProperties properties     = SharpDevelopTextEditorProperties.Instance;
                WixDocumentEditor     documentEditor = new WixDocumentEditor(textAreaControl);
                documentEditor.Insert(location.Y, location.X, String.Concat(xml, properties.LineTerminator));
                return(true);
            }
            return(false);
        }