Click here to Skip to main content
15,906,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am uploading file from asp.net 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">
maxRequestLength="200000"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="100"/>


here is my code:
--------------------

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




if (FileUpload1.HasFile)
try
{
FileUpload1.SaveAs(
uploadedFilePath + FileUpload1.FileName);

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

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

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

try
{
// 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;
}
finally
{
response.Close();
}
}

Posted
Updated 6-Aug-12 23:11pm
v6

XML
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">
</httpruntime>
 
Share this answer
 
Comments
Unareshraju 6-Aug-12 4:56am    
http://www.webdavsystem.com/server/documentation/large_files_iis_asp_net
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" %>

or:

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

<configuration>

<system.web>

<compilation debug="true">



Unareshraju 6-Aug-12 5:32am    
configuration
system.web
compilation debug="true"/
/system.web
/configuration

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900