L'esempio C# mostra come spostare un item da un folder ad un altro in SharePoint 2007 (WSS3 - MOSS).

C#

//move item / file
string url = "http://sharepoint2007/Lists/SgartTest";
using (SPSite site = new SPSite(url))
{
  using (SPWeb web = site.OpenWeb())
  {
    SPList list = web.GetList(url);
    int id = 25;
    bool overwrite = false;
    //get file to move (origin)
    SPListItem item = list.GetItemById(id);
    SPFile originItem = web.GetFile(item.Url);
    // get destination folder (first for example)
    SPListItem destFolder = list.Folders[0];
    //build destination path
    string destinationPath = string.Format("{0}/{1}/{2}"
      , web.Url
      , destFolder.Url
      , originItem.Name);
    //move item
    originItem.MoveTo(destinationPath, overwrite);
  }
}
Tags:
C#236 SharePoint498 SharePoint 2007218
Potrebbe interessarti anche: