HELP! WebClient.UploadFile() throws exception while uploading files to sharepoint
Posted
by Royson
on Stack Overflow
See other posts from Stack Overflow
or by Royson
Published on 2010-05-19T10:14:16Z
Indexed on
2010/05/19
11:40 UTC
Read the original article
Hit count: 431
In my application i am uploading files to sharepoint 2007. I am using
using (WebClient webClient = new WebClient())
{
webClient.Credentials = new NetworkCredential(userName, password);
webClient.Headers.Add("Content-Type", "application/x-vermeer-urlencoded");
webClient.Headers.Add("X-Vermeer-Content-Type", "application/x-vermeer-urlencoded");
String result = Encoding.UTF8.GetString(webClient.UploadData(webUrl + "/_vti_bin/_vti_aut/author.dll","POST", data.ToArray()));
}
the code is running successfully..but for some files it throws exception
The underlying connection was closed: The connection was closed unexpectedly. at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) at System.Net.WebClient.UploadData(Uri address, String method, Byte[] data)
at System.Net.WebClient.UploadData(String address, String method, Byte[] data)
Any Ideas what I have done wrong?
I am using VS-2008 2.0
© Stack Overflow or respective owner