Hi,
Ive created a process to upload multiple attachments using InfoPath repeating table to SP document library, Written the code in Btn click event. Please check the code below, it's working fine, now i'd like to save data rom few fields of InfoPath from, fields like Form Name, Form ID..I tried few options to add fields data to SP library while attachments upload but no luck
Could you please suggest how i can code to submit items to Library
This button i'm using to load attachments to Doc Library,
public void CTRL62_5_Clicked(object sender, ClickedEventArgs e)
{
// Write your code here.
XPathNavigator ipFormNav = MainDataSource.CreateNavigator();
XPathNodeIterator nodes = MainDataSource.CreateNavigator().Select("/my:Project/my:AddAttachmnet", this.NamespaceManager);
// XPathNavigator xnProjectName = MainDataSource.CreateNavigator().SelectSingleNode("/my:Project/my:ProjectName", this.NamespaceManager);
string attachmentValue = string.Empty;
string ProjectName = string.Empty;
foreach (XPathNavigator node in nodes)
if (node != null && !String.IsNullOrEmpty(node.Value)){
attachmentValue = node.Value;
InfoPathAttachmentDecoder dec = new InfoPathAttachmentDecoder(attachmentValue);
string fileName = dec.Filename + System.DateTime.Now.ToString("yyyyMMddHHmmssfff");
byte[] data = dec.DecodedAttachment;
// Add the file to a document library
using (SPSite site = new SPSite("web site addess"))
using (SPWeb web = site.OpenWeb()){
web.AllowUnsafeUpdates = true;
SPFolder docLib = web.Folders["Doc library"];
docLib.Files.Add(fileName, data);
//docLib.Item["ProjectName"] = xnProjectName;
web.AllowUnsafeUpdates = false;
web.Close();
}
site.Close();
}
}// If node is not null
}/ foreach nodes