码迷,mamicode.com
首页 > 其他好文 > 详细

Sharepoint 根据文件相对路径获取、操作SPFolder

时间:2017-02-23 21:00:25      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:bsp   spfile   false   var   业务   actor   上海   class   foreach   

 public AjaxResult LoadDocInfo(HttpContext httpContext)
        {
            var result = new ArrayList();
            try
            {
                var orgId = httpContext.Request["orgId"];
                var curFolder = DataFactory.GetOrganizationAppService().FindOrganizationsById(orgId);
                var curFolderPath = GetFolderPath(curFolder);//中国一维金融集团/弘达资本集团/上海中锋保理/业务部

                var curSite = SPContext.Current.Site;
                var curWeb = SPContext.Current.Web;
                SPSecurity.RunWithElevatedPrivileges(delegate
                {
                    using (var site = new SPSite(curSite.ID))
                    {
                        using (var web = site.OpenWeb(curWeb.ID))
                        {
                            SPFolder folder = web.GetFolder("/" + web.Name + "/Shared Documents/" + curFolderPath);
                            if (folder != null)
                            {
                                foreach (SPFile sf in folder.Files)
                                {
                                    result.Add(new
                                    {
                                        id = sf.UniqueId,
                                        name = sf.Name,
                                        length = sf.Length
                                    });
                                }
                            }
                        }
                    }
                });

                return new AjaxResult(true, result);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogArea.Service, LogLevelType.ERROR, "OrganizationService-LoadDocInfo", ex);
                return new AjaxResult(false, ex.Message);
            }
        }

 

Sharepoint 根据文件相对路径获取、操作SPFolder

标签:bsp   spfile   false   var   业务   actor   上海   class   foreach   

原文地址:http://www.cnblogs.com/lishidefengchen/p/6435259.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!