Kaip Redaguoti "InfoPath" XML failo Biblioteka Forumas programiškai "SharePoint" 2007

Žemiau eilučių kodo fragmentą atnaujinti InfoPath XML įrašas(failas)

SPWeb _web = SPContext.Current.Web;
SPList _list = _web.Lists[“SampleFormLib”];

MemoryStream myInStream = nauji MemoryStream(item.File.OpenBinary());
XmlTextReader skaitytojas = nauji XmlTextReader(myInStream);

XmlDocument doc = nauji XmlDocument();
doc.Load(skaitytojas);

reader.Close();
myInStream.Close();

XmlNamespaceManager nameSpaceManager = nauji XmlNamespaceManager(doc.NameTable);
nameSpaceManager.AddNamespace(“mano”, “http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-06-11T12:44:57“);

doc.DocumentElement.SelectSingleNode(“mano:Statusas”, nameSpaceManager).Vidinis tekstas = “Išsaugota”;
doc.DocumentElement.SelectSingleNode(“mano:SaveDate”, nameSpaceManager).InnerText = DateTime.Today.ToString();
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
SPFile newFile = _web.Folders[“SampleFormLib”].Files.Add(item.File.Name.ToString(), (encoding.GetBytes(doc.OuterXml)), tiesa);
item.File.Update();

Make sure you execute item.File.Update() to commit the changes (I got the errors while execute item.Update() and spent couple of hours to find 🙁 )

1 comment to How to Edit InfoPath XML File in Forum Library Programmatically in SharePoint 2007

Leave a Reply

Galite naudoti šiuos HTML tagai

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>