zoukankan      html  css  js  c++  java
  • sharepoint webpart 获取文档库下的所有文件夹名

    最近的项目需求中有一个这样的小功能,需要获取到文档库下的所有文件夹名称,并保存到dropdownlist中,代码如下。

    View Code
    protected void Page_Load(object sender, EventArgs e)
            {
                DataBindLoad();
            }
    
            private void DataBindLoad()
            {
                SPSecurity.RunWithElevatedPrivileges(delegate() { // 提升权限
                    try
                    {
                        string ServerUrl = (this.Parent as VisualWebPartUpload).SURL;       //设置的站点地址 http:// xunyi-sps/
                        string LibraryName = (this.Parent as VisualWebPartUpload).Library;  //文档库名称 测试文档库
    
                        using (SPSite site = new Microsoft.SharePoint.SPSite(ServerUrl))//获取站点
                        {
                            SPWeb spWeb = site.OpenWeb();//打开站点
                            spWeb.AllowUnsafeUpdates = true;// 提升权限
                            SPList docLib = spWeb.Lists[LibraryName]; //获取文档库对象
    
                            ///添加文件夹
                            if (this.DroplistType.Items.Count == 0) //将要添加文件夹名的下拉列表
                            {
                                foreach (SPListItem foldername in docLib.Folders) //循环文档库对象listitem Folders指示为文件夹
                                {
                                    this.DroplistType.Items.Add(new ListItem(foldername.Name.ToString(), foldername.UniqueId.ToString())); //添加到下拉列表
                                }
                            }
                        } 
                    }
                    catch (Exception ex)
                    {
                    }
                });
                
            }
  • 相关阅读:
    linux scull 函数open 方法
    linux scull 中的设备注册
    linux 字符设备注册
    linux inode 结构
    linux设备驱动文件结构
    linux一些重要数据结构
    Python3.2官方文档翻译--输出格式化
    1021. Deepest Root (25)
    hdu 4779 Tower Defense (思维+组合数学)
    cookie是什么? -- web
  • 原文地址:https://www.cnblogs.com/zchblog/p/3068780.html
Copyright © 2011-2022 走看看