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


  • 相关阅读:
    Insus Meta Utility
    The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
    Insus Binary Utility
    asp.net实现文件下载功能
    Column 'Column Name' does not belong to table Table
    程序已被编译为DLL,怎样去修改程序功能
    如何在Web网站实现搜索功能
    如何把数据流转换为二进制字符串
    Asp.net更新文件夹的文件
    如何显示中文月份
  • 原文地址:https://www.cnblogs.com/luking/p/2671664.html
Copyright © 2020-2023  润新知