views:

260

answers:

1

Hi all,

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

A: 

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);
    }
}
Rubens Farias
Thanx Rubens but i am not using Microsoft.Sharepoint.dll (sorry i din't mentioned it before in post).I am using Web services in my code.Can you give solution on that?
Jene
Take a look here: http://weblogs.asp.net/paulballard/archive/2005/05/08/Using-Data-From-SharePoint-2003-Lists.aspx
Rubens Farias