2017-05-08 44 views
0

的定義,我有以下代碼:不包含ListItemAllFields

public void ChangeFolderPermission() 
{ 
    SP.ClientContext ctx = new SP.ClientContext("https://sharepoint.oshirowanen.com/sites/oshirodev/"); 
    ctx.Credentials = new NetworkCredential("user", "pass", "domain"); 

    SP.Principal user = ctx.Web.EnsureUser("accountName"); 
    var folder = ctx.Web.GetFolderByServerRelativeUrl("folderUrl"); 
    var roleDefinition = ctx.Site.RootWeb.RoleDefinitions.GetByType(SP.RoleType.Reader); //get Reader role 
    var roleBindings = new SP.RoleDefinitionBindingCollection(ctx) { roleDefinition }; 
    folder.ListItemAllFields.BreakRoleInheritance(true, false); //set folder unique permissions 
    folder.ListItemAllFields.RoleAssignments.Add(user, roleBindings); 
    ctx.ExecuteQuery(); 
} 

但是下面幾行:

folder.ListItemAllFields.BreakRoleInheritance(true, false); //set folder unique permissions 
folder.ListItemAllFields.RoleAssignments.Add(user, roleBindings); 

給出了這樣的錯誤消息:

'Microsoft.SharePoint.Client.Folder' does not contain a definition for 'ListItemAllFields' and no extension method 'ListItemAllFields' accepting a first argument of type 'Microsoft.SharePoint.Client.Folder' could be found (are you missing a using directive or an assembly reference?) 

我有以下項目參考

Microsoft.SharePoint.Client 
microsoft.SharePoint.Client.Runtime 

我有以下使用指令

using SP = Microsoft.SharePoint.Client; 

任何想法,爲什麼我收到此錯誤?

該應用程序是一個從桌面環境運行的winform。

+0

愚蠢的問題我的一部分,但你不有定義文件夾對象時使用SP.folder,或者編譯器足夠聰明,可以根據您調用的函數知道返回類型。 – Eric

回答