Try to run it in VS 2005 and see what you get(web is Response.Write and console is console.write )

1     VirtualServer

            SPGlobalAdmin oSPGlobalAdmin = new SPGlobalAdmin();
           foreach (string name in oSPGlobalAdmin.VirtualServerNames)
           {
               Response.Write(name);
               Response.Write("<br>");
           }

2     Site and Web    
 
        SPSite spsite = new SPSite(http://server);
        foreach (SPWeb spweb in spsite.AllWebs)
        {
            Response.Write(spweb.Url);
        }

3     user and group

        SPSite spsite = new SPSite(http://server);
        SPWeb spweb= ss.OpenWeb();
        foreach (SPUser su in spweb.SiteUsers)
        {
            Response.Write(su.Name);
            Response.Write("<br>");
        }


        SPSite spsite = new SPSite(http://server);
        SPWeb spweb= ss.OpenWeb();
        foreach (SPGroup group in spweb.Groups)
        {
            Response.Write(group .Name);
            Response.Write("<br>");
        }

4 list and item

        SPSite spsite = new SPSite(http://server);
        SPWeb spweb = spsite.OpenWeb()
        foreach (SPList splist in spweb.Lists)
        {
            Response.Write(splist.Title);
        }

        SPList mytask = spweb.Lists["Documents"];
        SPListItemCollection splistitem = mytask.Items;
        foreach (SPListItem listitem in splistitem)
        {
            Response.Write(SPEncode.HtmlEncode(listitem["Title"].ToString()) + " :: " +
            SPEncode.HtmlEncode(listitem["Status"].ToString()) + "<BR>");
        }

posted on 2006-07-19 09:47  有些伤感  阅读(551)  评论(0编辑  收藏  举报