Thursday 4 October 2012

Move listitems programatically to sub folder in sharepoint 2010


  1. SPWeb web= properties.Web;  
  2. //Folder123 is Inside root location of List  
  3. string DestinationFolderName="Folder123";  
  4.   
  5. // Source item outside folder Folder123   
  6. SPListItem listitem = properties.ListItem;  
  7.   
  8. SPFile listitemFile = web.GetFile(listitem.Url);  
  9.   
  10. //Create New Destination  URL ../Lists/Folder123/1_.000  
  11. string NewDestinationUrl=listitemFile.Url.Replace(listitem.ID.ToString()+"_.000",DestinationFolderName+"/"+listitem.ID.ToString()+"_.000");   
  12.   
  13. //Move Item Insite Folder123  
  14. listitemFile.MoveTo(NewDestinationUrl); 

No comments:

Post a Comment