简体   繁体   中英

How to attach a current Word document to a new Sharepoint 2013 list item

I am develop a word addin . And i need create a new item in a existing Sharepoint list, with the current document like attachment.

var attInfo = new AttachmentCreationInformation();
attInfo.FileName = "Test";
attInfo.ContentStream = new MemoryStream(System.IO.File.ReadAllBytes(**here my current document**));
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem oListItem = oList.AddItem(itemCreateInfo);
oListItem["Title"] = "My New Item!";    
oListItem.AttachmentFiles.Add(attInfo);

How i put my current document there. Appreciate your help. Regards

保存文档后,** ActiveDocument ** Path 属性,有完整路径

 attInfo.ContentStream = new MemoryStream(System.IO.File.ReadAllBytes(**Globals.ThisAddIn.ActiveDocument.FullName**));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM