用lists.asmx web service 获取文件夹中的文件数量 - SharePoint 2010

本文介绍了一种使用C#代码通过SharePoint Web服务获取特定文件夹中项目总数的方法。示例代码展示了如何设置Web服务连接、构建查询选项并解析返回的数据以得到文件夹内的项目数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

listWebService.Lists listService = new listWebService.Lists();
            listService.Url = "http://emiliu:8081/team2/_vti_bin/Lists.asmx";
            listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
            
                    
            XmlDocument xmlDoc = new System.Xml.XmlDocument();
            XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
          
            XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
            //We need to get count of items in dept1 folder
            //Please change folder name and library name according to your requirement
            ndQueryOptions.InnerXml = "<Folder>form_library_name/dept1</Folder>";
                     
            XmlNode ndListItems = listService.GetListItems("form_library_name", null, ndQuery, null, null, ndQueryOptions, null);
            System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
            xd.LoadXml(ndListItems.OuterXml);
            System.Xml.XmlNamespaceManager nm = new System.Xml.XmlNamespaceManager(xd.NameTable);
            
            nm.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
            nm.AddNamespace("z", "#RowsetSchema");
            nm.AddNamespace("rootNS", "http://schemas.microsoft.com/sharepoint/soap/");
            //This is the total count of items in dept1 folder
            int currentCount = xd.SelectNodes("/rootNS:listitems/rs:data/z:row", nm).Count;

 

转载于:https://www.cnblogs.com/liuliu66/archive/2013/05/27/3101579.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值