开发者

How to get list of Folders and subfolders created in "List"?

开发者_开发问答

I am trying to access list of all Sites and Lists from Sharepoint 2007 using c#. I am able to get Name of sites and list. But unable to get folders and subfolders of particular list. And Document uploaded in particular Folder.

I am using Web Services (no dependency of Microsoft.Sharepoint.dll)

Regards,

Jene


Try this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜