【问题标题】:How to get list of Folders and subfolders created in "List"?如何获取在“列表”中创建的文件夹和子文件夹列表?
【发布时间】:2010-03-10 19:24:59
【问题描述】:

我正在尝试使用 c# 从 Sharepoint 2007 访问所有站点和列表的列表。 我能够获取站点名称和列表。 但无法获取特定列表的文件夹和子文件夹。 并将 Document 上传到特定的文件夹中。

我正在使用 Web 服务(不依赖 Microsoft.Sharepoint.dll)

问候,

杰恩

【问题讨论】:

    标签: c# sharepoint-2007


    【解决方案1】:

    试试这个:

    using(SPSite site = new SPSite("http://yoursite"))
    using(SPWeb web = site.OpenWeb())
    {
        SPList list = web.Lists["your_doclib"];
        SPQuery query = new SPQuery()
        {
            Query = "",
            ViewAttributes = @"Scope=""RecursiveAll"""
        };
        SPListItemCollection itens = list.GetItems(query);
        foreach (SPListItem item in itens)
        {
            Console.ForegroundColor =
                item.FileSystemObjectType == SPFileSystemObjectType.Folder ?
                    ConsoleColor.White : ConsoleColor.Gray;
            Console.WriteLine("{0}", item.Name);
        }
    }
    

    【讨论】:

    • Thanx Rubens,但我没有使用 Microsoft.Sharepoint.dll(抱歉,我之前在帖子中没有提到它)。我在我的代码中使用了 Web 服务。你能给出解决方案吗?
    猜你喜欢
    • 1970-01-01
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 2011-01-15
    • 2021-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多