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 8612709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:41:40+00:00 2026-06-12T04:41:40+00:00

The code below, is an attempt to get (download) files from a sharepoint. If

  • 0

The code below, is an attempt to get (download) files from a sharepoint.
If I try this on my local version, it works like a charm. I can select all items in the document library.

There are several methods I’ve tried, and I could post some of them here if you like. I can download corrupt files, but even when the link is wrong.
If I try this on the TeamSite in Office 365, I get an exception that my link is wrong. But I’m referring to the same site (instead of localhost/dev/ im referring to http://mysite.com/TeamSite/dev/). Any idea what the difference can be? Does Microsoft block something so external connections aren’t allowed?

  private void btnDownload_Click(object sender, EventArgs e)
    {
        if (comboBox1.Items.Count > 0 && comboBox1.SelectedIndex != -1)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.ShowDialog();

            using (SPSite site = new SPSite("http://localhost/dev/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPFolder myLibrary = web.Folders["Management"];

                    foreach (SPFile file in myLibrary.Files)
                    {
                        if (file.Name == comboBox1.SelectedItem.ToString())
                        {
                            byte[] bytes = file.OpenBinary();

                            try
                            {
                                FileStream fs = new FileStream(dialog.FileName, FileMode.Create, FileAccess.ReadWrite);
                                BinaryWriter bw = new BinaryWriter(fs);
                                bw.Write(bytes);
                                bw.Close();
                                MessageBox.Show("File downloaded to: " + dialog.FileName);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }

                        }                            
                    }
                }
            }
        }
        else
        {
            MessageBox.Show("Select file to download");
        }
    }

This is the Exception message:

The Web application at http://www.gtest.nl/TeamSite/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
  • 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-12T04:41:41+00:00Added an answer on June 12, 2026 at 4:41 am

    You can not connect to sharepoint site, deployed on another computer like this.
    You should use Client Context

    for example:

        string siteUrl = "http://MyServer/sites/MySiteCollection";
    
        ClientContext clientContext = new ClientContext(siteUrl);
        Web oWebsite = clientContext.Web;
        ListCollection collList = oWebsite.Lists;
    
        clientContext.Load(collList);
    
        clientContext.ExecuteQuery();
    
        foreach (SP.List oList in collList)
        {
            Console.WriteLine("Title: {0} Created: {1}", oList.Title, oList.Created.ToString());
        }
    

    you could find more examples on Client Context here

    There is allready an example of file download from sharepoint through clientContext.

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

Sidebar

Related Questions

This code below allows me to find the word error in all my files
The code below works well right now; however, it's serially executed. I'd like to
I am in attempt to get CPU Usage reading correctly. The code below is
Below is the code I am using and the error happens when I attempt
Code below is used to save PostgreSql database backup from browser in Apache Mono
The code below simply didn't work. document.getElementById('files').addEventListener('change', handleFileSelect, false); reported by firebug that this
The code below works as intended, but it's not quite what I need. I
In mysql I have this code below: $row = mysql_fetch_assoc($query); $dbactive = $row['active']; if
I'm using this code to download a web page in my Metro Style app:
Dear fellow homo sapiens, I've created this graph using the code below (except without

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.