WriteFile() public static method

public static WriteFile ( String fileName, byte fileContent ) : bool
fileName String
fileContent byte
return bool
Esempio n. 1
0
        public static void ExportMessages()
        {
            HelpDAO dao = new HelpDAO();
            List <HelpMessageBean> messages = dao.getHelpMessages();
            XmlDocument            document = new XmlDocument();
            XmlElement             root     = document.CreateElement("messages");

            document.AppendChild(root);
            foreach (HelpMessageBean messageBean in messages)
            {
                XmlElement message = document.CreateElement("message");
                message.SetAttribute("key", messageBean.messageKey);
                XmlText txt = document.CreateTextNode(messageBean.message);
                message.AppendChild(txt);
                root.AppendChild(message);
            }

            StringWriter sw     = new StringWriter();
            XmlWriter    writer = new UTRSXmlWriter(sw);

            document.WriteContentTo(writer);
            if (FileManager.WriteFile(Encoding.UTF8.GetBytes(sw.ToString()), "help-messages.xml"))
            {
                LogManager.Info("Help Messages have been successfully exported.");
            }
        }