Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have here a piece of code which loops through the all site collections and webs and lists to find particular and modify some items:

foreach (SPSite site in webApp.Sites)
                {
                    foreach (SPWeb web in site.AllWebs)
                    {
                        SPFeature feature = web.Features[new Guid(strGuid)];

                       if (feature == null)
                        {
                            continue;
                        }

                        //Feature is activated, proceed!

                        //Loop through all the lists in web
                        foreach (SPList list in web.Lists)
                        {
                            if (!(list is SPDocumentLibrary))
                            {
                                continue;
                            }

                            if (list.Fields.ContainsField(strFieldName))
                            {
                                //TODO, modify set of items
                            }
                        }     
                    }
                }

But I have an issue on first time when it gets to if (!(list is SPDocumentLibrary)) it jumps out and out ... anyone has any idea why?

Or is my approach wrong and something goes wrong?

I don't get any errors tho, but it is as if the collections are empty, but it isn't, there are still plenty of webs and lists to check out.

PS: it is in sharepoint 2007

share|improve this question
add comment

1 Answer

you can check whether splist is document library or not by using following condition.

if (list.BaseType == SPBaseType.DocumentLibrary) { }

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.