zoukankan      html  css  js  c++  java
  • MOSS2010 客户端对象模型开发(四)

    讲完了几个常用列表的操作,现在讲述一下列表的附件的获取。列表的附件存放的相对地址一般是在列表的跟目录下Attachment文件夹下面,在客户端的对象模型中,我们依然遵循这个思路进行解决办法,通过路径的方式访问文件夹,然后遍历得到附件的信息,下面是示例代码。

      using (ClientContext clientContext = new ClientContext(url))
                    {
                        clientContext.Credentials = new NetworkCredential(UserName, UserPassword, Domain));
                        Web web = clientContext.Web;
                        clientContext.Load(web);

                        Folder attachmentsFolder = web.GetFolderByServerRelativeUrl(webUrl + "Lists/" + listUrl + "/attachments/" + listIiteId);
                        clientContext.Load(attachmentsFolder);
                        FileCollection attachments = attachmentsFolder.Files;

                        clientContext.Load(attachments);

                        List<FileInformation> attInfoList=new List<FileInformation>();

                        foreach (File f in attachments)
                        {
                            attInfoList.Add(File.OpenBinaryDirect(clientContext,f.ServerRelativeUrl);
                        }


  • 相关阅读:
    Oracle 绑定变量窥视
    MongoDB 查看chunk块大小
    Linux 查看实时网卡流量的几种方式
    MongoDB 集合与文档操作
    MongoDB 副本集的常用操作及原理
    MongoDB 副本集主从切换方法
    MongoDB 副本集节点添加与删除
    Linux 硬件软件时间同步
    Linux ntp 时间同步服务配置
    MongoDB oplog详解
  • 原文地址:https://www.cnblogs.com/luking/p/2671664.html
Copyright © 2011-2022 走看看