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();
}
}