Serialize object to xml and save in document library & then retrieve

gold10

New Member
I am trying to serialize an object to xml and then store it in a sharepoint style library without using the file system. I currenly have the following which works using a path to a folder on the C drive. I have tried using SPContext/Web.URL to write to a relative path but this hasn't worked! Any help is appreciated.\[code\]var serializer = new XmlSerializer(typeof (List<NavItem>)); var path = web.Url + Constants.MegaMenuXmlFilePath; TextWriter tw = new StreamWriter(path); serializer.Serialize(tw, mainNav); tw.Close();var serializer = new XmlSerializer(typeof(List<NavItem>)); TextReader tr = new StreamReader(Constants.MegaMenuXmlFilePath); var nav = (List<NavItem>)serializer.Deserialize(tr); tr.Close(); return nav;\[/code\]
 
Back
Top