copy specific file from one server documet library to another using client object model

Hi,

I have one xml file on in document library of one server.its not present in any folder.

I want to copy this xml file from that servers document library to my servers document library.

I am using the following code to access the document library,

                   


string siteUrl = "http://abc.com/sites/MyData/";

Microsoft.SharePoint.Client.ClientContext clientContext = new Microsoft.SharePoint.Client.ClientContext(siteUrl);

 Microsoft.SharePoint.Client.List docList = clientContext.Web.Lists.GetByTitle("DocumentLibraryName");

Microsoft.SharePoint.Client.List myxmlfile= clientContext.Web.Lists.GetByTitle("MyXMLFileName");

System.Net.WebProxy proxy = new System.Net.WebProxy(siteUrl, true);
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
clientContext.Credentials = proxy.Credentials;

clientContext.Load(docList);

Microsoft.SharePoint.Client.CamlQuery camlQuery = new Microsoft.SharePoint.Client.CamlQuery();
                           camlQuery.ViewXml = @"<View>
                                            <Query>
                                                <Where>
                                                <Eq>
                                                    <FieldRef Name='Title'/>
                                                    <Value Type='Text'>ABC.xml</Value>
                                                </Eq>
                                                </Where>
                                                <RowLimit>1</RowLimit>
                                            </Query>
                                            </View>";
 Microsoft.SharePoint.Client.ListItemCollection collListItem = docList.GetItems(camlQuery);                                                     

clientContext.Load(collListItem);

clientContext.ExecuteQuery();

this code returns   me item collection wich actually have files of documen library.

What should I do to copy that xml file to my document library without any permissing issue.

February 19th, 2014 1:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics