Click here to Skip to main content
15,888,337 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
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:

C#
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);
Posted
Updated 29-Mar-16 3:04am
v2
Comments
Patrice T 28-Mar-16 9:48am    
Where is the error ?
What is the size of the URI ?
Sergey Alexandrovich Kryukov 28-Mar-16 10:49am    
What do you mean by "pass"? XML is not a function with arguments to pass an object.
Don't you make some URL containing base64 string?
—SA
VR Karthikeyan 28-Mar-16 13:28pm    
You can't load normal string with xmlDoc.Load function, From your code, you are loading base64 string from xmlDoc.Load function, it is incorrect, this function only loads xml string. If you want to store video bytes in xml, then define a xml table and insert byte string of the video in it.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900