我正在编写一个程序,其中我使用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(); }
答案 0 :(得分:2)
你的问题在这里:
ndListItems = list.GetListItems(ListName, "", ndQuery, ndViewFields, "1000", ndQueryOptions, null)
您指定了1000个项目的行限制。将其更改为:
ndListItems = list.GetListItems(ListName, "", ndQuery, ndViewFields, "2000", ndQueryOptions, null)