Creating Sites and Sub Sites


http://www.asaris.de/sites/walsh/Lists/WSSv3%20FAQ/DispForm.aspx?ID=691

Site Creation

SPSite mySite = SPControl.GetContextSite(this.Context); 
mySite.WebApplication.Sites.Add("sites/" + SiteName.Text,
SiteName.Text, SiteName.Text, Convert.ToUInt32(1033), "STS#0",
Administrator","Administrator", email@xxx.com);

Sub-Site Creation:

SPWeb myweb = SPControl.GetContextWeb(this.Context);
SPWebCollection mycol = myweb.Webs;
SPWeb newweb = mycol.Add(SiteName.Text, SiteName.Text, SiteName.Text,
Convert.ToUInt32(1033), "STS#0", false, false);

Posting SharePoint Dicussion Forums programatically


Posting email

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;

namespace Discussions
{
class UserGroup 
 {
   static void Main(string[] args)
   {
      SPSite siteCollection = new SPSite(http://jerry/SiteDirectory/Site1);

      using (SPWeb aweb = siteCollection.OpenWeb())
      {
         SPList aList = aweb.Lists[".NET User Group"];
         SPListItemCollection lstCollection = aList .Items;
         SPListItem aDiscussion= SPUtility.CreateNewDiscussion(myListCol, "C Sharp");
         aDiscussion["Body"] = "Difference Between VB & VB.NET";
         aDiscussion.Update();
      }
   }
 }

}

Using Disposable WSS objects – Best and Bad Practices


The objects in the Microsoft Windows SharePoint Services (version 3) object model serve as an interface for working with Windows SharePoint Services data and configuration. Frequently, developers call into the object model to read or write new data in the Windows SharePoint Services store.

The Windows SharePoint Services object model contains objects that implement the IDisposable interface. You must take precautions when using these objects to avoid their long-term retention in memory in the Microsoft .NET Framework. Specifically, you should explicitly dispose of those SharePoint objects when you are finished using them.

In scenarios in which you use SharePoint objects extensively—for example, in SharePoint sites that use custom Web Parts—you can cause the following unusual behaviors by not disposing of those objects that can be disposed of:

  • Frequent recycles of the Microsoft Windows SharePoint Services application pool, especially during peak usage
  • Application crashes that appear as heap corruption in the debugger
  • High memory use for Microsoft Internet Information Services (IIS) worker processes
  • Poor system and application performance

This article serves as a guide to the proper procedures for handling and disposing of SharePoint objects

Best Practices: Using Disposable Windows SharePoint Services Objects