I cannot upload large files in Sharepoint 2010. I am using Visual Studio 2010 and Language C #. I tried several ways from the content that I found on the Internet, but nothing worked. I changed the settings and configuration files to the maximum allowable download limits and still nothing. I use copy.asmx for small files that work fine, and I try to load UploadDataAsync when the file is too large and an exception is thrown, but this does not work. Please take a look at the code below ...
Any / all help is 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();
source share