Take the 2-minute tour ×

How to move an item from custom list root location to sub folder programmatically (in Event Receiver (ItemAdded))?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You can identify a custom list's root folder using SPList.Rootfolder property and corresponding subfolders could be accessed using SPList.Rootfolder.SubFolders[index].

While adding the list item, make sure that it is added to the correct folder path.

SPListItem listitem = list.Items.Add(folder.ServerRelativeURL,SpFileSystemObjectType.File)

Sample code might look like this.

     using (SPWeb web = properties.OpenWeb())
           SPList list = web.Lists["Test"];

           if (properties.List.Title == list.Title)
               foreach (SPFolder folder in properties.List.RootFolder.SubFolders)
                   if (folder.Name == "Specific Folder Name")
                       SPListItem listItem = list.Items.Add(folder.ServerRelativeUrl, SPFileSystemObjectType.File);
                       listItem["FieldName"] = properties.ListItem["FieldName"];

share|improve this answer

This solution allow you to move to any folder in same or different list http://think4code.blogspot.com/2012/03/move-list-item-splistitem-to-sub-folder.html

share|improve this answer
We require relevant answers and disclosure of any affiliation with products or websites. Please see May I promote products or websites I am affiliated with here? for guidelines. –  SPDoctor Jul 5 '12 at 22:30

Your Answer


