2012-03-11 4 views
0

Я пишу программу, в которой я использую список webservice sharepoint и метод webclient.DownloadFile для C# для загрузки всех файлов в список. Список содержит 1800 файлов, которые отображаются на 18 страницах, что приводит к 100 файлам на каждой странице. Однако мой код загружает файлы только на первых 10 страницах (1000 файлов из 1800 файлов). Кто-нибудь знает, в чем проблема? Вот мой кодЗагрузка из списка Sharepoint с помощью webservice

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

ответ

2

Ваша проблема здесь:

ndListItems = list.GetListItems(ListName, "", ndQuery, ndViewFields, "1000", ndQueryOptions, null) 

Вы определили предел строки из 1000 элементов. Измените его так:

ndListItems = list.GetListItems(ListName, "", ndQuery, ndViewFields, "2000", ndQueryOptions, null) 
+0

О, какая ошибка, которую я совершил! Большое вам спасибо :) –

+0

@ user1260960: лучший способ поблагодарить sga101 - щелкнуть стрелку вверх и принять галочку ответа на этот вопрос. –

Смежные вопросы