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);
                        }


  • 相关阅读:
    mycat 查询sql 报错
    mysql 主从 binlog
    数据库分库分表思路
    JavaScript数组知识
    JS判断当前页面是在 QQ客户端/微信客户端/iOS浏览器/Android浏览器/PC客户端
    js汉字转换为拼音
    工作中常用到的JS验证
    自动部署服务器代码
    php Excel 导入
    PHP 模拟http 请求
  • 原文地址:https://www.cnblogs.com/luking/p/2671664.html
Copyright © 2011-2022 走看看