Bagaimana untuk Mengedit InfoPath XML fail dalam Forum Perpustakaan pengaturcaraan dalam SharePoint 2007

Garisan di bawah kod coretan adalah untuk mengemas kini rekod xml InfoPath(fail)

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

MemoryStream myInStream = MemoryStream baru(item.File.OpenBinary());
Pembaca XmlTextReader = XmlTextReader baru(myInStream);

XmlDocument doc = XmlDocument baru();
doc.Load(pembaca);

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

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

doc.DocumentElement.SelectSingleNode(“saya:Status”, nameSpaceManager).Teks Inner = “Disimpan”;
doc.DocumentElement.SelectSingleNode(“saya: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)), benar);
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

Tinggalkan Reply

Anda boleh menggunakan tag HTML ini

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