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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:13:17+00:00 2026-06-02T20:13:17+00:00

I am unable to upload large files to Sharepoint 2010. I am using Visual

  • 0

I am unable to upload large files to Sharepoint 2010. I am using Visual Studio 2010 and Language C#. I have tried multiple ways from content I have found online but nothing has worked. I have changed the settings and config files to the maximum allowed upload limits and still nothing. I am using the copy.asmx for small files which works fine and am trying UploadDataAsync when the file is too large and an exception is thrown but this is not working. Please take a look at the code below…

Any/all assistance is greatly appreciated.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace ListsService
{

    public class UploadDocumentcs
    {
        public string UploadResult { get; set; }
        public string Errors { get; set; }
        public UploadDataCompletedEventHandler WebClient_UploadDataCompleted { get; set; }
        public byte[] content { get; set; }

        public void UploadDocumentToSP(string localFile, string remoteFile)
        {
            string result = string.Empty;
            SPCopyService.CopySoapClient client = new SPCopyService.CopySoapClient();

            string sUser = "user";
            string sPwd = "pwd";
            string sDomain = "dmn";
            System.Net.NetworkCredential NC = new System.Net.NetworkCredential(sUser, sPwd, sDomain);

            client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            client.ClientCredentials.Windows.ClientCredential = NC;

            try
            {
                client.Open();

                string url = "http://SP/TestLibrary/";
                string fileName = localFile.Substring(localFile.LastIndexOf('\\'), (localFile.Length - localFile.LastIndexOf('\\')));
                fileName = fileName.Remove(0, 1);
                string[] destinationUrl = { url + fileName };

                System.IO.FileStream fileStream = new System.IO.FileStream(localFile, System.IO.FileMode.Open);
                byte[] content = new byte[(int)fileStream.Length];
                fileStream.Read(content, 0, (int)fileStream.Length);
                fileStream.Close();

                // Description Information Field
                SPCopyService.FieldInformation descInfo = new SPCopyService.FieldInformation
                                                  {
                                                      DisplayName = "Description",
                                                      Type = SPCopyService.FieldType.File,
                                                      Value = "Test file for upload"
                                                  };

                SPCopyService.FieldInformation[] fileInfoArray = { descInfo };

                SPCopyService.CopyResult[] arrayOfResults;

                 uint result2 = client.CopyIntoItems(fileName, destinationUrl, fileInfoArray, content, out arrayOfResults);                

                // Check for Errors
                 foreach (SPCopyService.CopyResult copyResult in arrayOfResults)
                 {
                     string msg = "====================================" +
                                  "SharePoint Error:" +
                                  "\nUrl: " + copyResult.DestinationUrl +
                                  "\nError Code: " + copyResult.ErrorCode +
                                  "\nMessage: " + copyResult.ErrorMessage +
                                  "====================================";


                     Errors = string.Format("{0};{1}", Errors, msg);
                 }
                 UploadResult = "File uploaded successfully";

            }
            catch (OutOfMemoryException)
            {
                System.Uri uri = new Uri("http://bis-dev-srv2:300/DNATestLibrary/");
                (new System.Net.WebClient()).UploadDataCompleted += new UploadDataCompletedEventHandler(WebClient_UploadDataCompleted);
                (new System.Net.WebClient()).UploadDataAsync(uri, content);

            }

            finally
            {
                if (client.State == System.ServiceModel.CommunicationState.Faulted)
                {
                    client.Abort();
                    UploadResult = "Upload aborted due to error";
                }

                if (client.State != System.ServiceModel.CommunicationState.Closed)
                {
                    client.Close();
                }
            }
        }


        void WcUpload_UploadDataCompleted(object sender, UploadDataCompletedEventArgs e)
        {

            if (e != null)
            {
                UploadResult = "Upload Unuccessful";
            }
            else
            {
                UploadResult = "Upload Successful";
                //throw new NotImplementedException();
            }
        }
    }
}
  • 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-02T20:13:18+00:00Added an answer on June 2, 2026 at 8:13 pm
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Net;
    using System.IO;
    namespace UploadTester
    {
        public partial class frmMain : Form
        {
            public frmMain()
            {
                InitializeComponent();
            }
    
            private void btnSelectFile_Click(object sender, EventArgs e)
            {
                openFileDialog1.ShowDialog();
                textBox1.Text = openFileDialog1.FileName;
            }
    
            private void btnUpload_Click(object sender, EventArgs e)
            {
                try
                {
                    byte[] content = GetByteArray();
                    string filename = Path.GetFileName(openFileDialog1.FileName);
    
                    System.Net.WebClient webClient = new System.Net.WebClient();
                    System.Uri uri = new Uri("http://SP/DNATestLibrary/" + filename);
                    webClient.Credentials = new NetworkCredential("username", "pwd", "domain");
    
                    webClient.UploadData(uri, "PUT", content);
    
                    MessageBox.Show("Upload Successful");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
    
            byte[] GetByteArray()
            {
                FileStream fileStream = new System.IO.FileStream(openFileDialog1.FileName, System.IO.FileMode.Open);
                byte[] content = new byte[(int)fileStream.Length];
                fileStream.Read(content, 0, (int)fileStream.Length);
                fileStream.Close();
    
                return content;
            }
    
            private void btnUploadAsync_Click(object sender, EventArgs e)
            {
                try
                {
                    byte[] content = GetByteArray();
                    string filename = Path.GetFileName(openFileDialog1.FileName);
    
                    System.Net.WebClient webClient = new System.Net.WebClient();
                    System.Uri uri = new Uri("http://SP/DNATestLibrary/" + filename);
    
                    webClient.UploadDataCompleted += new UploadDataCompletedEventHandler(webClient_UploadDataCompleted);
                    webClient.Credentials = new NetworkCredential("username", "pwd", "domain");
    
                    webClient.UploadDataAsync(uri, "PUT", content);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
    
            void webClient_UploadDataCompleted(object sender, UploadDataCompletedEventArgs e)
            {
                if (e.Error == null)
                {
                    MessageBox.Show("Upload Successful");
                }
                else
                {
                    MessageBox.Show(e.ToString());
                }
    
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting upload multiple files in ASP.NET MVC and I have this simple foreach
I tried to use Amazon-SDK(Java) sample code S3TransferProgressSample.java to upload large files to Amazon-S3
I have upload the video on facebook using following code Help From : https://github.com/zoul/facebook-ios-sdk/
i am unable to connect to visual studio remote debugger when it is running
I have to upload a 3gp audio file to my server using MultipartEntity. i
I have this code that i use to upload files on the server. But
I am using jQuery Form upload. I am unable to upload file with the
I'm trying to upload images using Graph API Batch Request, but i'm unable to
I am using plupload to upload files then redirect to an acknowledgement page. What
one of the users who is using my signed applet is unable to upload

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.