Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9187371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:45:06+00:00 2026-06-17T19:45:06+00:00

I want to download the files from a sharepoint document library through code as

  • 0

I want to download the files from a sharepoint document library through code as there are thousand of files in the document library.

I am thinking of creating console application, which I will run on sharepoint server and download files. Is this approach correct or, there is some other efficient way to do this.

Any help with code will be highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:45:07+00:00Added an answer on June 17, 2026 at 7:45 pm

    Like SigarDave said, it’s perfectly possible to achieve this without writing a single line of code. But if you really want to code the solution for this, it’s something like:

    static void Main(string[] args)
    {
      // Change to the URL of your site
      using (var site = new SPSite("http://MySite")) 
      using (var web = site.OpenWeb())
      {
        var list = web.Lists["MyDocumentLibrary"]; // Get the library
        foreach (SPListItem item in list.Items)
        {
          if (item.File != null)
          {
            // Concat strings to get the absolute URL
            // to pass to an WebClient object.
            var fileUrl = string.Format("{0}/{1}", site.Url, item.File.Url);            
            var result = DownloadFile(fileUrl, "C:\\FilesFromMyLibrary\\", item.File.Name);
            Console.WriteLine(result ? "Downloaded \"{0}\"" : "Error on \"{0}\"", item.File.Name);
          }
        }
      }
      Console.ReadKey();
    }
    
    private static bool DownloadFile(string url, string dest, string fileName)
    {
      var client = new WebClient();
    
      // Change the credentials to the user that has the necessary permissions on the 
      // library
      client.Credentials = new NetworkCredential("Username", "Password", "Domain"); 
      var bytes = client.DownloadData(url);
    
      try
      {
        using (var file = File.Create(dest + fileName))
        {
          file.Write(bytes, 0, bytes.Length); // Write file to disk
          return true;
        }
      }
      catch (Exception)
      {
        return false;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to download files from internet in my Android Native application. I was
I want to ask if I can download files from the blobstore in google
I want to ask if I can download files from the blobstore in google
All I have used osmdroid and i want to download map zip files from
i want maven to download custom jar files from an ftp how to set
I want to enable the users of my website to download the files from
Let say I want to create an iOS app that download music files from
My company has a local production server I want to download files from that
I want to use wget to download files linked from the main page of
I want to download the source files from a project in sourceforge with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.