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

  • SEARCH
  • Home
  • 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 6978815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:48:18+00:00 2026-05-27T17:48:18+00:00

I made a windows form application which maps whole of spsite (given in text

  • 0

I made a windows form application which maps whole of spsite (given in text box) in form of tree View, but i am wondering if user selects to download whole Site, what code i will be required, i looked into google but find code to download one file or folder which is given below,

Downloading a folder

private void bFolder_Click(object sender, EventArgs e)
    {
            TreeNode currentNode = TreeFolder.SelectedNode;
                SPFolder oFolder = (SPFolder)currentNode.Tag;
                foreach (SPFile file in oFolder.Files)
                {
                    if (CreateDirectoryStructure(tbDirectory.Text, file.Url))
                    {
                        var filepath = System.IO.Path.Combine(tbDirectory.Text, file.Url);
                        byte[] binFile = file.OpenBinary();
                        System.IO.FileStream fstream = System.IO.File.Create(filepath);
                        fstream.Write(binFile, 0, binFile.Length);
                        fstream.Close();
                    }
                }
    }

//creating directory        
private bool CreateDirectoryStructure(string baseFolder, string filepath)
        {
            if (!Directory.Exists(baseFolder)) return false;

            var paths = filepath.Split('/');

            for (var i = 0; i < paths.Length - 1; i++)
            {
            baseFolder = System.IO.Path.Combine(baseFolder, paths[i]);
            Directory.CreateDirectory(baseFolder);
        }
        return true;
    }
  • 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-05-27T17:48:19+00:00Added an answer on May 27, 2026 at 5:48 pm

    Try this:

    SPSite oSiteCollection = SPContext.Current.Site;
    SPWebCollection collWebsites = oSiteCollection.AllWebs;
    foreach (SPWeb oWebsite in collWebsites)
    {
    
    
    SPFolderCollection collFolders = oWebsite.Folders;
    
      foreach (SPFolder oFolder in collFolders)
      {
    
                foreach (SPFile file in oFolder.Files)  
                {
                     // Your code here
                }
    
      }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

net windows form application. I have a combo box and a text box and
i have a windows application made in VB.NET which maintains a database, and i
I'm Using Process.Start from my website to open a windows form application I made
I have an application which I have made a 256 x 256 Windows Vista icon
I Made an application to download a folder from a given sharepoint site, but
I have a visual c++ windows form application (empty) made on visual studio 2008
So i have created Windows Form Application and made a library added a reference
i made a windows service & add project installer.in which only contain this code.
I have been made a windows service.in which i have been added project installer.in
I made a C# windows application in visual c# express 2008. I executed the

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.