如何将base64字符串传递给XML文件? [英] How to pass base64 string to XML file ?

查看:196
本文介绍了如何将base64字符串传递给XML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将值传递给xml文件,但它给出了错误无效的URI:Uri字符串太长



我有什么试过:



i tried to pass the value to xml file but it gives me error "Invalid URI: The Uri string is too long"

What I have tried:

byte[] videobytes = File.ReadAllBytes("C:test.wmv");
                string result = System.Convert.ToBase64String(videobytes);
           
                // Create the XmlDocument.
                XmlDocument xmlDoc = new XmlDocument();
                XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                // Add a price element.
                XmlElement rootNode = xmlDoc.CreateElement("Clip");
                xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement);
                xmlDoc.AppendChild(rootNode);
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;
                xmlDoc.Load(result);
                // Save the document to a file and auto-indent the output.
                XmlWriter writer = XmlWriter.Create("C:data.xml", settings);
                xmlDoc.Save(writer);

推荐答案

使用xml序列化和反序列化。

by使用它你可以在xml中转换你的类的对象。在你的课堂对象中你可以设置值。
Use xml serialization and deserialization.
by using it you can convert object of your class in xml. and in your object of class you can set value.


这篇关于如何将base64字符串传递给XML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆