• 递归获取SharePoint文档库文件夹内的所有文件


    代码
    private DataTable GetFilesData()
    {
    SPList list
    = GetList();
    DataTable dt
    = CreateDatatable();
    SPFolder f
    = null;
    try
    {
    if (string.IsNullOrEmpty(_folderName))
    f
    = list.RootFolder;
    else
    f
    = list.RootFolder.SubFolders[_folderName];
    if (!string.IsNullOrEmpty(_subFolder))
    f
    = f.SubFolders[_subFolder];
    GetAllFiles(f,
    ref dt, list.ID.ToString("B"));
    }
    catch
    { }
    return dt;
    }

    private void GetAllFiles(SPFolder f, ref DataTable dt, string listId)
    {
    SPListItem item;
    foreach (SPFile file in f.Files)
    {
    item
    = file.Item;
    DataRow dr
    = dt.NewRow();
    dr[
    "IconUrl"] = file.IconUrl; //item["DocIcon"];
    string newTag = "";
    if (file.TimeCreated.AddDays(2) > DateTime.Now)
    newTag
    = "<img border='0' src='/_layouts/2052/images/new.gif'/>";
    dr[
    "NewTag"] = newTag;
    dr[
    "DocItemID"] = item.ID;
    dr[
    "DocListID"] = listId;
    dr[
    "FileRef"] = item["FileRef"];
    dr[
    "Title"] = item["Title"];
    dr[
    "Author"] = file.Author.Name;
    dr[
    "Created"] = item["Created"];
    dr[
    "Modified"] = item["Modified"];
    dr[
    "Category1"] = item["Category1"];
    dr[
    "Category2"] = item["Category2"];
    dr[
    "SecurityLevel"] = item["SecurityLevel"];
    dr[
    "BaseName"] = item["BaseName"];
    dt.Rows.Add(dr);
    }
    foreach (SPFolder sf in f.SubFolders)
    {
    GetAllFiles(sf,
    ref dt, listId);
    }
    }

    出处: http://www.cnblogs.com/windy2008

  • 相关阅读:
    数据库查询服务框架
    postgresql清理工具
    postgre索引
    SAP模块一句话入门(专业术语的理解)
    SAP订单结算详解
    SAP Datasheet
    ASP.NET MVC5 网站开发实践
    VMware S/4 HANA OP 1511虚拟机下载,64G内存限制解决方案
    SAP标准教材列表
    SAP文章链接
  • 原文地址:https://www.cnblogs.com/windy2008/p/1855432.html
Copyright © 2020-2023  润新知