Click here to Skip to main content
13,289,653 members (57,650 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am uploading file from application to sharepoint document library.
upto 50MB Files uploading well.when i upload more than 50MB its not allowing.

my IIS is IIS 6.0.

how to do that.

in sharepoint document library under WEB APPLICATION GENERAL SETTING i have set

file upload size to 200MB But its not working.

and web.config i added this:

<httpruntime executiontimeout="3600">

here is my code:

protected void btnUpload_Click(object sender, EventArgs e)
string uploadedFilePath = @"E:\New Folder\";
string sharePointListPath =

if (FileUpload1.HasFile)
uploadedFilePath + FileUpload1.FileName);

Label1.Text = "File name: " +
FileUpload1.PostedFile.FileName + "
" +
FileUpload1.PostedFile.ContentLength + " bytes
" +
"Content type: " +

uploadedFilePath + FileUpload1.FileName,
sharePointListPath + FileUpload1.FileName);
catch (Exception ex)
Label1.Text = "ERROR: " + ex.Message.ToString();
Label1.Text = "You have not specified a file.";

protected void UploadFileToSharePoint(string UploadedFilePath,string SharePointPath)
WebResponse response =null;

// Create a PUT Web request to upload the file.
WebRequest request = WebRequest.Create(SharePointPath);

request.Credentials = CredentialCache.DefaultCredentials;

request.Method = "PUT";

// Allocate a 1 KB buffer to transfer the file contents.
// You can adjust the buffer size as needed, depending on
// the number and size of files being uploaded.
byte[] buffer = new byte[1024];

// Write the contents of the local file to the
// request stream.
using (Stream stream = request.GetRequestStream())
using (FileStream fsWorkbook = File.Open(UploadedFilePath,
FileMode.Open, FileAccess.Read))
int i = fsWorkbook.Read(buffer, 0, buffer.Length);

while (i > 0)
stream.Write(buffer, 0, i);
i = fsWorkbook.Read(buffer, 0, buffer.Length);

// Make the PUT request.
response = request.GetResponse();
catch (Exception ex)
throw ex;

Posted 5-Aug-12 22:47pm
Updated 7-Aug-12 0:11am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Generally, the uploading limit of ASP.NET FileUploader is 4MB. But you can increase the limit of length of uploaded file by using the following code into your web.config file in your website.
<httpruntime maxrequestlength="20480" executiontimeout="600">
Unareshraju 6-Aug-12 4:56am
oliver grace 6-Aug-12 5:07am
<httpruntime maxrequestlength="20480" executiontimeout="600">

I have tried httpruntime but i am getting this error.
ERROR: Object reference not set to an instance of an object.
Unareshraju 6-Aug-12 5:29am
he source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@ Page Language="C#" Debug="true" %>


2) Add the following section to the configuration file of your application:



<compilation debug="true"/>

Unareshraju 6-Aug-12 5:32am
compilation debug="true"/

in the tags
oliver grace 6-Aug-12 5:46am
still I have same error :
ERROR: Object reference not set to an instance of an object
Unareshraju 6-Aug-12 5:57am
if possible can u show you r code?
Unareshraju 6-Aug-12 5:58am
please see her for more details where u did wrong.
Unareshraju 6-Aug-12 5:59am
oliver grace 6-Aug-12 6:14am
hi, I have added my code here:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 7 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100