我正在尝试下载网络及其子网络及其子网络(如果存在)的所有内容(文档、列表、文件夹)等等,我可以为单个网络执行此操作,但它不适用于其中的子网络,代码如下,
private void downloadList(SPObjectData objectData)
{
using (SPWeb currentWeb = objectData.Web)
{
foreach (SPList list in currentWeb.Lists)
{
foreach (SPFolder oFolder in list.Folders)
{
if (oFolder != null)
{
foreach (SPFile file in oFolder.files)
{
if (CreateDirectoryStructure(tbDirectory.Text, file.Url))
{
var filepath = System.IO.Path.Combine(tbDirectory.Text, file.Url);
byte[] binFile = file.OpenBinary();
System.IO.FileStream fstream = System.IO.File.Create(filepath);
fstream.Write(binFile, 0, binFile.Length);
fstream.Close();
}
}
}
}
}
}
}