SharePoint Copy large document library by CSOM
class Program
{
static void Main(string[] args)
{
ClientContext clntContext = new ClientContext("https://<<SiteUrl>>");
FileCollection collFile = clntContext.Web.GetFolderByServerRelativeUrl("https://<<DocumentLibraryUrl>>/").Files;
clntContext.Load(collFile);
clntContext.ExecuteQuery();
foreach (File file in collFile)
{
file.CopyTo("<<Destiation document library url>>" + file.Name, true);
Console.WriteLine(file.Name + " is copied successfully");
clntContext.Load(file);
clntContext.ExecuteQuery();
}
Console.ReadLine();
}
}
}
{
static void Main(string[] args)
{
ClientContext clntContext = new ClientContext("https://<<SiteUrl>>");
FileCollection collFile = clntContext.Web.GetFolderByServerRelativeUrl("https://<<DocumentLibraryUrl>>/").Files;
clntContext.Load(collFile);
clntContext.ExecuteQuery();
foreach (File file in collFile)
{
file.CopyTo("<<Destiation document library url>>" + file.Name, true);
Console.WriteLine(file.Name + " is copied successfully");
clntContext.Load(file);
clntContext.ExecuteQuery();
}
Console.ReadLine();
}
}
}
Comments
Post a Comment