Kako urediti InfoPath XML datoteke v knjižnici Forum Programsko v SharePoint 2007

Spodaj vrstic programske kode je posodobiti InfoPath xml rekord(datoteka)

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

MemoryStream myInStream = new MemoryStream(item.File.OpenBinary());
XmlTextReader bralec = new XmlTextReader(myInStream);

XmlDocument doc = new XmlDocument();
doc.Load(Bralec);

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

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

doc.DocumentElement.SelectSingleNode(“moja:Status”, nameSpaceManager).Notranja Text = “Shranjeno”;
doc.DocumentElement.SelectSingleNode(“moja:SaveDate”, nameSpaceManager).InnerText = DateTime.Today.ToString();
System.Text.ASCIIEncoding kodiranje = new System.Text.ASCIIEncoding();
SPFile newFile = _web.Folders[“SampleFormLib”].Files.Add(item.File.Name.ToString(), (encoding.GetBytes(doc.OuterXml)), Res);
item.File.Update();

Poskrbite, da boste izvršiti item.File.Update() da se zavežejo spremembe (Imam napake, medtem ko izvaja item.Update() and spent couple of hours to find 🙁 )

1 komentar na Kako urediti InfoPath XML datoteke v knjižnici Forum Programsko v SharePoint 2007

Leave a Reply

Lahko uporabite te HTML oznake

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