SharePoint:使用Web服务将文件从一个文档库移动到另一个文档库

时间:2013-08-28 06:51:47

标签: c# web-services sharepoint-2010

要求Windows窗体应用程序可以访问列表列表,以便用户可以选择源列表和目标列表。

我在访问网站集中的列表时遇到问题。我通过 _vti_bin / ListData.svc 访问网站的 XML ,在这里我可以获取特定列表的项目。

如何访问列表列表并移动文件?

以下是我的代码:

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();

    }

此处的代码只能从代码中的特定列表中获取项目。

1 个答案:

答案 0 :(得分:1)

列表服务仅用于提取信息。要执行更改,您需要使用Sharepoint客户端对象模型。

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