0

I'm using the following code to create new list folder:

Folder newFolder = listCopyTo.RootFolder.Folders.Add("NewFolder");
clientContext.Load(newFolder);
clientContext.ExecuteQuery();

After that the new folder is exist in the list (i checked it). But it doesn't dispay in browser (view). I found an article on this issue. It says the folowing:

SPListItem newFolder = reportingList.Items.Add(reportingList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, “New_Folder_Name”);
//the following line will associate a list item with the newly created folder and make the folder visible in the list views
newFolder.Update();

But i can't to follow this way because i'm using SharePoint 2010 Client-Side Object Model. Is there the right decision for me?

2 Answers 2

0

I cannot comment your post yet, so I take a shot at answering.

Have you checked in your view parameters that you are allowing the folders to be displayed ?

One other thing, in your List advanced settings, do allow folders to be created in your list ?

1
  • Hammer, thanks for reply! I haven't checked the parameter that allow the folders to be displayed and if you said it's name and it's class then i will check it at work tommorow. But i created the new folder via SharePoint web interface and it normally displayed on browser. What about EnableFolderCreation parameter of my List so i set it on "True", but it didn't help(
    – Nebiross
    May 20, 2015 at 16:42
0

So i resolved this issue. New folder of List must be added like new ListItem by List.AddItem(ListItemCreationInformation parameters) method. Just need to set ListItemCreationInformation.UnderlyingObjectType to FileSystemObjectType.Folder.

Example:

List listCopyTo = ClientContext.Web.Lists.GetByTitle("ListName");
ListItemCreationInformation newFolderInfo = new ListItemCreationInformation();
newFolderInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
ListItem newFolder = listCopyTo.AddItem(newFolderInfo);
newFolder["Title"] = folder.Name;
newFolder.Update();
clientContext.ExecuteQuery();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.