Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Copy/Move documents to another library SharePoint 2013
Ravi Kumar
Jul 13 2015 3:13 AM
1.1k
Reply
Hello,
I have written a event receiver code in SharePoint 2013 Item updated event to edit metadata properties of the document and copying\moving it to another library.
It is working for a MS word & Excel older versions like(.doc , .xls , .txt , .png etc)
It is not working for a MS word & Excel older versions like(.docx , .xlsx)
my code is as below
using (SPSite site = new SPSite("http://yoursiteurl"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["test"];
SPListItem item = properties.ListItem;
//add metadata
Hashtable ht = new Hashtable();
ht.Add("testcol", "myfile");
ht.Add("vti_title", "mytitle");
SPFile destfile = list.RootFolder.Files.Add(item.File.Name, item2.File.OpenBinary(), ht, true);
destfile.update();
}
}
Many thanks in advance
Thanks
Ravi Patil
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Sharepoint 2013 Export and Import subsite
SharePoint 2013