承接MOSS各种工作流开发 联系人:王先生.电话:18618405729QQ:252385878 QQ群:41696750 MSN:wanghao-3@hotmail.com

导航

SharePoint SPQuery类简单测试

     关于简单对象模型的操作,希望对开发人员有帮助!
  static void GoThroughList(SPList list, SPFolder folder, int level)
        {
            SPQuery query = new SPQuery();
            query.Folder = folder;
            SPListItemCollection items = list.GetItems(query);
            if (items.Count == 0)
                return;

            for (int i = 0; i < level; i++)
                Console.Write("  ");
            foreach (SPListItem item in items)
            {
                if (item.FileSystemObjectType == SPFileSystemObjectType.Folder)
                {
                    Console.WriteLine("[{0}]", item.Name);
                    GoThroughList(list, item.Folder, level + 1);
                }
                else
                    Console.WriteLine(item.Name);
            }
        }


                SPWeb web = (new SPSite("http://moss/sites/hello")).OpenWeb();
                SPList list = web.Lists["test"];
                list.Lists.IncludeRootFolder = true;
                GoThroughList(list, list.RootFolder, 0);

posted on 2007-06-12 13:16  A A  阅读(1447)  评论(3编辑  收藏  举报