简体   繁体   English

有什么方法可以使用C#获取共享点文档的自定义列/属性值?

[英]Is there any way to get custom column/property value of sharepoint document using c#?

below code working fine and gives me list of all files into sharepoint site. 下面的代码工作正常,并向我提供了所有进入sharepoint网站的文件的列表。

i get standard properties of file like item.File.Author and item.File.ModifiedBy but not custom item.File.Location 我得到像item.File.Author and item.File.ModifiedBy but not custom item.File.Location这样的文件的标准属性, item.File.Author and item.File.ModifiedBy but not custom item.File.Location

    // Sharepoint Object Model Code
    ClientContext clientContext = new ClientContext("siteurl"); 
    clientContext.Credentials = new NetworkCredential("username","password");
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.Load(web.Lists);
    clientContext.Load(web, wb => wb.ServerRelativeUrl);
    clientContext.ExecuteQuery();
    List list = web.Lists.GetByTitle("My Doc");
    clientContext.Load(list);
    clientContext.ExecuteQuery();

    Folder folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + @"My Doc");
    clientContext.Load(folder);
    clientContext.ExecuteQuery();

    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = @"<View Scope='RecursiveAll'>
                             <Query>
                             </Query>
                         </View>";
    camlQuery.FolderServerRelativeUrl = folder.ServerRelativeUrl;
    ListItemCollection listItems = list.GetItems(camlQuery);
    clientContext.Load(listItems);
    clientContext.ExecuteQuery();
    FileInformation fileInfo;

    foreach (var item in listItems)
    {
       // How to get File custom properties ? i.e Location , Path , Flat
       // I can get standard properties of file like - 
       // item.File.Author and item.File.ModifiedBy but not item.File.Location

在此处输入图片说明

To get "Location","Path" value, we need use the code below: 要获取“位置”,“路径”值,我们需要使用以下代码:

var location=item["Location"];
var path=item["Path"];

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在使用 C# 将文档作为项目上传到 SharePoint 文档库时为自定义列添加值? - How to add value to a custom column while uploading document into a SharePoint document library as an item using C#? C#使用自定义属性从对象获取属性值 - C# get property value from object using custom attribute 使用C#将SharePoint库XML文档转换为PDF文档 - Convert SharePoint Library XML document to PDF document using C# 如何获取无法使用C#中的AutomationElement属性访问的自定义属性值 - How to get a custom property value which cannot be accessed using AutomationElement properties in c# 有什么方法可以使用c#获取特殊符号(如“ GS”)的ascii值? - Is there any way to get the ascii value of special symbols like 'GS' using c#? 在C#中获取属性(反射)的最快方法 - Fastest way for Get Value of a property (Reflection) in C# 在C#中使用属性“ get {}”,“ set {}”或“ =&gt;”语法有什么区别? - Are there any differences when using Property “get {}”, “set {}” or “=>” syntax in C#? 有什么方法可以在C#中动态创建属性? - Is there any way to create property dynamically in c#? 如果另一列的值使用C#和CAML匹配,则共享点列表中列值的总和 - Sum of column values in sharepoint list if value for another column matches using C# and CAML 使用列名字符串从列中获取值 c# - Get value from column using a column name string c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM