copy.asMx service to upload document from local desktop to Sharepoint using web service.
//Copy WebService Settings
CopyTo.
CopySoapClient WSCopy = new CopyTo.CopySoapClient();
WSCopy.ClientCredentials.Windows.ClientCredential.Domain =
"XYZ";
WSCopy.ClientCredentials.Windows.ClientCredential.Password =
"abc";
WSCopy.ClientCredentials.Windows.ClientCredential.UserName =
"GHYP";
//Declare and initiates the Copy WebService members for uploading
string sourceUrl = "D:\\Logs\\AutoResponder.xml";
string[] destinationUrls = {"
http://www.c-sharpcorner.com/code/AutoResponder.xml"
};
CopyTo.
CopyResult cResult1 = new CopyTo.CopyResult();
CopyTo.
CopyResult cResult2 = new CopyTo.CopyResult();
CopyTo.
CopyResult[] cResultArray = { cResult1, cResult2 };
CopyTo.
FieldInformation fFiledInfo = new CopyTo.FieldInformation();
fFiledInfo.InternalName =
"Test";
fFiledInfo.Type = CopyTo.
FieldType.Text;
fFiledInfo.Value =
"Hellos";
CopyTo.
FieldInformation[] fFiledInfoArray = { fFiledInfo };
FileStream strm = new FileStream(sourceUrl, FileMode.Open, FileAccess.Read);
byte[] fileContents = new Byte[strm.Length];
byte[] r = new Byte[strm.Length];
int ia = strm.Read(fileContents, 0, Convert.ToInt32(strm.Length));
strm.Close();
//Copy the document from Local to SharePoint
uint copyresult = WSCopy.CopyIntoItems(sourceUrl, destinationUrls, fFiledInfoArray, fileContents, out cResultArray);