Saturday 3 September 2011

Copy web service Sharepoint 2010 example


A simple example of using the Copy web service in Sharepoint 2010 -

webRef.Copy copyService = new EncryptAndDecrypt.webRef.Copy();

copyService.Url = "http://SPSite_vti_bin/copy.asmx";

copyService.Credentials = System.Net.CredentialCache.DefaultCredentials;

string DestinationUrl = "http:\\SPsite\DestinationList\...";
string strSource = "http:\\SpSite\SourceList\...";

FileStream objStream = new FileStream(strSource, FileMode.Open, FileAccess.Read);
byte[] Contents = new Byte[objStream.Length];
byte[] r = new Byte[objStream.Length];
int Read= objStream.Read(Contents, 0, Convert.ToInt32(objStream.Length));
objStream.Close();

uint copyresult = copyService.CopyIntoItems(strSource, DestinationUrl, null, Contents, out ArrayOfResult);

Ads by Google

No comments:

Post a Comment