I have a provider hosted SharePoint app. I need to add a custom action item "copy" in the context menu of a list item. On click of copy I should get a duplicate of that item at the bottom in the same list in SharePoint online. Any suggestions?
1 Answer
I got the solution:
// get the file
File file = sourceItem.File;
clientContext.Load(file);
clientContext.ExecuteQuery();
char[] chars = { '.' };
var fileName = file.Name.Split(chars);
// build destination url
string locationUrl = web.ServerRelativeUrl.TrimEnd('/') + "/" + destinationList.Title + "/" + fileName[0] + "-Copy." + fileName[1];
// read the file, copy the content to new file at new location
file.CopyTo(locationUrl, true);
clientContext.ExecuteQuery();
The above code would do the work !