【发布时间】:2019-12-16 19:16:41
【问题描述】:
我正在尝试以编程方式从 Sharepoint 2007 站点上的文档文件夹中下载所有文件。到目前为止,我能够连接到该站点,但是在连接到文件夹和下载它们时遇到了问题。
try{
using(SPSite site = new SPSite("http://mysharepointserver/sites/subsite")){
using(SPWeb web = site.OpenWeb()){
Console.Write("Connected to site");
SPFolder testFolder = web.Folder["testFolder"];
//example method downloading folder
downloadFolder(testFolder);
}
}
}
catch(Exception e){
Log(e.ToString());
}
我的控制台编写工作正常,所以我知道我正确连接到该站点。 我的日志文件输出:
System.ArgumentException: Value does not fall within the expected range.
at Microsoft.SharePoint.SPListCollection.GetListByName(String strListName, Boolean bThrowException)
at Microsoft.SharePoint.SPListCollection.get_Item(String strListName)
我还尝试打印出以下内容:
using(SPWeb web = site.OpenWeb()){
Console.Write("Connected to site");
Console.Write(web.lists);
SPFolder testFolder = web.Folder["testFolder"];
//example method downloading folder
downloadFolder(testFolder);
}
向控制台输出以下内容:
Connected to site
Microsoft.SharePoint.SPListCollection
但我不确定如何通过 SPListCollection 导航以检索我的文件夹“testFolder”
任何帮助将不胜感激。谢谢!
【问题讨论】:
标签: c# .net sharepoint sharepoint-2007