TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ravi Kumar
1.6k
192
20.4k
Copy/Move documents to another library SharePoint 2013
Jul 13 2015 3:13 AM
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
Reply
Answers (
3
)
Sharepoint 2013 Export and Import subsite
SharePoint 2013