Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 文件夹中的文件列表,SharePoint 2010中通过其ASMX web服务的列表中的文件列表_C#_.net_Web Services_Sharepoint_Sharepoint 2010 - Fatal编程技术网

C# 文件夹中的文件列表,SharePoint 2010中通过其ASMX web服务的列表中的文件列表

C# 文件夹中的文件列表,SharePoint 2010中通过其ASMX web服务的列表中的文件列表,c#,.net,web-services,sharepoint,sharepoint-2010,C#,.net,Web Services,Sharepoint,Sharepoint 2010,我正在尝试使用SharePoint 2010的web服务列出文件夹的内容 这就是我到目前为止所做的,告诉我我是否把事情复杂化了,如果是的话 XNamespace z = "#RowsetSchema"; string lId = this.GetListID("Account"); string vId = this.GetViewID("All Documents", lId); //this below, works, I'm getting the unique ID of folder.

我正在尝试使用SharePoint 2010的web服务列出文件夹的内容

这就是我到目前为止所做的,告诉我我是否把事情复杂化了,如果是的话

XNamespace z = "#RowsetSchema";
string lId = this.GetListID("Account");
string vId = this.GetViewID("All Documents", lId);
//this below, works, I'm getting the unique ID of folder...
string folderId = this.GetListData(lId, vId).Descendants(z + "row").
            Where(x => x.Attribute("ows_LinkFilename").Value.Equals("FolderName")).
            Select(x => x.Attribute("ows_UniqueId").Value).SingleOrDefault().ToString();    

private string GetListID(string listName)
{
    string listID;

    try
    {
        XDocument doc = XDocument.Parse(_listClient.GetListCollection().ToString());
                listID = (from x in doc.Elements().First().Elements()
                          where x.Attribute("Title").Value.Equals(listName)
                          select x.Attribute("ID").Value).FirstOrDefault();
    }
    catch
    {
        throw;
    }

    return listID;
}

private string GetViewID(string viewName, string listID)
{
    string viewID = null;

    try
    {
        XDocument doc = XDocument.Parse(_viewClient.GetViewCollection(listID).ToString());
            viewID = (from x in doc.Elements().First().Elements()
                      where x.Attribute("DisplayName").Value.Equals(viewName)
                      select x.Attribute("Name").Value).FirstOrDefault();

     }
     catch
     {
            throw;
     }

     return viewID;
}

 private XDocument GetListData(string listID, string viewID)
 {
     XDocument list_data = null;

     try
     {
            list_data = XDocument.Parse(_listClient.GetListItems(listID, viewID, null, null, "10000", null, null).ToString());
            var q = (from x in list_data.Elements().First().Elements().First().Elements()
                     select new
                    {
                        Title = x.Attribute("ows_LinkTitle").Value,
                        Field1 = x.Attribute("ows_Field1").Value,
                        Field2 = x.Attribute("ows_Field2").Value
                    });
     }
     catch
     {
         throw;  
     }


    return list_data;
}
正如您所看到的,我能够获得有关文件夹的唯一ID。那又怎么样?是否有其他SharePoint web服务需要与文件夹ID一起使用才能获取其内容

下面是我试图获取其内容的URL结构示例:

https://spsite.domain.ca/testenv/account/000001
上面的代码为我检索文件夹
000001
的唯一ID,但是我被卡在那里了。。。我在
lists.asmx
或其他SP web服务中没有看到任何
GetFolderItems
或类似的内容

我在那里看到了一些示例,但它们使用程序集
Microsoft.Sharepoint.dll
来执行此操作,这是我试图避免的

谢谢大家!

我将为此使用。我不知道SP2010+提供了这样的功能