Frage

My scenario: I have a list that i am iterating to get all subfolders files and updating those files. I cant seem to get to the list item name to pass a parameter for FolderserverRelativeUrl.

foreach (ListItem item in folderItems)
            {
                if (item.FileSystemObjectType == FileSystemObjectType.File)
                {
                    item["Title"] = "Test";
                    item.Update();
                    list.Update();
                    clientContext.ExecuteQuery();

                }
                else if (item.FileSystemObjectType == FileSystemObjectType.Folder)
                {
                    // item is a folder
                    String SubFolderUrl = folderServerRelativeUrl + "/" + item["Title"]; 

                    GetFolderItems(SubFolderUrl, list,clientContext);

                }
            }
War es hilfreich?

Lösung

As mentioned in comments, you need to use the built-in field, FileLeafRef.

FileLeafRef is the field which contains the actual name of the file in a document library.

Secondly, in your code I see that you are passing the folderServerRelativeUrl.

You can probably replace that with FileRef which is another built-in field containing the server-relative URL of the file in a doc lib.

The code can be somewhat as below:

// item is a folder
String SubFolderUrl = item["FileRef"]; 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top