I have the following code that creates an XML file in memory, updates it and then adds it to a form library.
// Creates a new XML document in memory
XmlDocument newCRF = new XmlDocument();
// Loads an existing XML file into that in-memory document
newXMLdoc.Load("Template.xml");
// Write the XML file to a document library
using (SPSite newSite = new SPSite("http://sharepoint/newsite"))
{
using (SPWeb newWeb = newSite.OpenWeb())
{
SPList newLibrary = newWeb.Lists["Test Library"];
byte[] xmlData = System.Text.Encoding.UTF8.GetBytes(newXMLdoc.OuterXml);
// Save file to form library
using (MemoryStream ms = new MemoryStream(xmlData))
{
SPFile newFileInLibrary = newLibrary.RootFolder.Files.Add("Filename.xml", ms);
}
}
}
How can I access the 'newFileInLibrary' object so that I can make changes to it's properties (such as "Created By")?
You can get the
SPListItem
object by using this code :Ps: did you considered posting on http://sharepoint.stackexchange.com ?