JG Vimalan's Blog

It is all about coding!

Programmatically move items from one document library to another

The following code snippet explains the way to move items in one document library to another in a simple way.

I assume that, you got a SPListItem object.


SPListItem spItem = itemCollection[0];

SPFile srcFile = spWeb.GetFile(spItem.Url);

SPList destDocLib = spWeb.Lists[“MyDestDocLibName”];

srcFile.MoveTo(destDocLib+ “/” + srcFile.Name, true); 

The above code will move the document (item) from source document library to the destination.


September 27, 2010 - Posted by | SharePoint

1 Comment »

  1. It only works in features and web parts. Does not work in console apps.

    Comment by Clem | October 11, 2012 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: