Programmatically copy files from one document library to anothet library in SharePoint


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
namespace
CopyTo
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://serverName:1111/SitePages/Home.aspx"))
{
using (SPWeb web = site.RootWeb)
{
SPFileCollection collFile = web.GetFolder("Shared Documents").Files;
foreach (SPFile file in collFile)
{
file.CopyTo(
"Destination Library/"+file.Name,true);
Console.WriteLine(file.Name + " is copied successfully");
}
}
Console.ReadLine();
}
}
}
}
Ebook Download
View all
Learn
View all