Christian Eric Paran
Christian Eric Paran

Reputation: 1010

SharePoint: Move files from one document library to another using Web Services

The requirment is that the Windows Form Application could access the Lists list so the user can choose the Source List and the Destination List.

I am having a problem accessing the Lists from the site collection. I access the XML of the site by _vti_bin/ListData.svc, here i can get the items of the SPECIFIC LIST.

How do access the Lists list and move the Files?

Here are my codes:

private void setContents(string strSource, string strDestination, string strUser,
        string strPW, string strDomain)
    {
        sourceContent = new SourceSiteDataContext(
        new Uri(strSource));
        destinationContent = new DestinationSiteDataContext(
        new Uri(strDestination));

        userContext = new NetworkCredential();

        userContext.UserName = strUser;
        userContext.Password = strPW;
        userContext.Domain = strDomain;
        sourceContent.Credentials = userContext;
        destinationContent.Credentials = userContext;
    }

ArrayList list = new ArrayList();           
        var sourceQuery = from sourceList in sourceContent.SourceLibrary
                          select new
                          {
                              sourceList.Name
                          };
        foreach (var item in sourceQuery)
        {
            list.Add(item.Name);
        }

private void Form1_Load(object sender, EventArgs e)
    {
        setContents("http://[site]:[port]/_vti_bin/ListData.svc",
            "http://[site]:[port]//sites/DestinationSite/_vti_bin/ListData.svc",
            "admin", "admin", "localhost");
        setDropDown();

    }

the Code here can only take items from a specific list in the code.

Upvotes: 0

Views: 1042

Answers (1)

Gonzix
Gonzix

Reputation: 1206

The list services are for pulling information only. To perform changes you will need to use the Sharepoint client object model.

Check MSDN http://msdn.microsoft.com/en-us/library/ee857094%28office.14%29.aspx

Upvotes: 1

Related Questions