1

I am using sharepoint 2013 which has document libraries consists of around 150gb data which i need to download it to my hard drive..one of the method that i came across is.

open with explorer

are there any other methods?

  • How open are you to using PowerShell / C#? – eirikb Feb 24 '14 at 7:18
  • i have powershell script but downloading 150gb data doesnt seems to be feasible option as we need to consider type of files, connection, sessions problem etc. if u have any c# code , then it would be helpful – user3265723 Feb 24 '14 at 7:20
  • Have you seen sharepoint.stackexchange.com/questions/44724/… ? – eirikb Feb 24 '14 at 7:25
  • yes..bt nt able to understand it :P.. – user3265723 Feb 24 '14 at 7:32
1

You could use the REST service, but since you are downloading this amount of data you could as well use the CSOM.
Try this:

Install the Microsoft.SharePoint.Client package from NuGet:

Install-Package Microsoft.SharePoint.Client

(This package is for 2010, but it will work for 2013 as well).
Then use this code:

const string host = "http://2013-sp";
const string documentLibTitle = "Documents";
const string savePath = @"C:\Temp";
using (var ctx = new Microsoft.SharePoint.Client.ClientContext(host))
{
    var items = ctx.Web.Lists.GetByTitle(documentLibTitle).GetItems(new Microsoft.SharePoint.Client.CamlQuery());
    ctx.Load(items);
    ctx.ExecuteQuery();

    System.Linq.Enumerable.ToList(items).ForEach(item => 
    {
        var path = "" + item["FileRef"];
        var name = "" + item["FileLeafRef"];
        using (var fileStream = System.IO.File.Create(System.IO.Path.Combine(savePath, name)))
        {
            var file = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctx, path);
            file.Stream.CopyTo(fileStream);
        }
    });
}

If you need to authenticate with username/password do this:

using (var ctx = new Microsoft.SharePoint.Client.ClientContext(host)
{
    Credentials = new NetworkCredential("username", "password", "DOMAIN")
})
{

Note that the file here is a stream, so you can write out the progress if you like.

  • this is faster or with powershell? – user3265723 Feb 24 '14 at 8:52
  • I think that depends if you are sitting on the server or not, with PowerShell you might want to use remote powershell, and then it will probably have the same speed, but without the ability to print information about progress pr. file. – eirikb Feb 24 '14 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.