Programmatically move the files from one document library to another library in SharePoint


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
namespace
MoveTo
{
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;
int count = collFile.Count;
while(count!=0)
{
collFile[count-1].MoveTo(
"Destination Library/" + collFile[count-1].Name, true);
count--;
}
}
}
}
}
}
Ebook Download
View all
Learn
View all