![](/img/trans.png)
[英]Accessing list from Sharepoint Webservice with Sharepoint Online 2013
[英]Downloading from a Sharepoint list using webservice
我正在編寫一個程序,在其中我使用sharepoint的列表webservice和C#的webclient.DownloadFile方法來下載列表中的所有文件。 該列表包含1800個文件,以18頁顯示,每頁顯示100個文件。 但是,我的代碼只下載前10頁中的文件(1800個文件中的1000個文件)。 任何人都知道問題是什么? 這是我的代碼
XmlNode ndListItems = null;
XmlDocument xdoc = new XmlDocument();
XmlNode ndQuery = xdoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xdoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xdoc.CreateNode (XmlNodeType.Element, "QueryOptions", "");
ndQuery.InnerXml = "";
ndViewFields.InnerXml = "";
ndQueryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>";
ndListItems = list.GetListItems(ListName, "", ndQuery, ndViewFields, "1000", ndQueryOptions, null);
if (ndListItems!=null)
{ foreach (XmlNode node in ndListItems.ChildNodes) { if ( node.Name=="rs:data")
{ string[] foldernames = new string[node.ChildNodes.Count];
for (int i = 0; i < node.ChildNodes.Count; i++) { if (node.ChildNodes[i].Name == "z:row" && node.ChildNodes[i].Attributes != null)
{ string fileurl= node.ChildNodes[i].Attributes["ows_ServerUrl"].Value;
string filename = node.ChildNodes[i].Attributes["ows_LinkFilename"].Value;
string contenttype = node.ChildNodes[i].Attributes["ows_ContentType"].Value;
string copysource = serverAddress + fileurl;
Uri copyUrl = new Uri(copysource);
if (contenttype=="Folder")
{ foldernames[i] = filename;
Directory.CreateDirectory(copyDestination+ filename); continue; } try {
int index = FolderNamseContain(filename, copysource, foldernames);
if (index != -1) { wc.DownloadFile(copysource, copyDestination + foldernames[index] + "\\" + filename);
report.Write(fileurl);
report.WriteLine();
report.Flush(); }
你的問題在這里:
ndListItems = list.GetListItems(ListName, "", ndQuery, ndViewFields, "1000", ndQueryOptions, null)
您已指定行限制為1000個項目。 把它改成這個:
ndListItems = list.GetListItems(ListName, "", ndQuery, ndViewFields, "2000", ndQueryOptions, null)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.