How can I write custom code that creates a new item in a Sharepoint form library? The only way I find out is to open an existing item via the object model and modify its nodes. But what can I do if no file exists?
This is my current approach (that uses an existing file to create a new one):
SPFile spTemplate = webSite.Folders[libraryName].Files[0];
// reads the blank file into an xml document
MemoryStream inStream = new MemoryStream(spTemplate.OpenBinary());
XmlTextReader reader = new XmlTextReader(inStream);
XmlDocument xd = new XmlDocument();
xd.Load(reader);
reader.Close();
inStream.Close();
XPathNavigator xpn = xd.CreateNavigator();
xpn.SelectNode(...).SetValue(newValue);