SPDocumentLibrary CurrentLibrary = null;
SPFolder CurrentFolder = null;
SPQuery query = new SPQuery();
List<SPFolder> ListFolders = new List<SPFolder>();
List<HyperLink> ListLinkPath = new List<HyperLink>();
int CurrentSubFolderNum = 0;
bool CurrentIsLibraryRoot = false;
string ViewRelativeUrl = string.Empty;
#region 属性初始化
SPSecurity.RunWithElevatedPrivileges(delegate()
{
CurrentLibrary = (SPDocumentLibrary)SPContext.Current.List;
CurrentFolder = SPContext.Current.Web.GetFolder(SPContext.Current.RootFolderUrl);
CurrentIsLibraryRoot = CurrentLibrary.RootFolder.ServerRelativeUrl == CurrentFolder.ServerRelativeUrl;
var query = from item in CurrentFolder.SubFolders.OfType<SPFolder>()
where item.Name.ToLower() != "forms" && item.Name.ToLower() != "temp"
select item;
CurrentSubFolderNum = query.Count();
ViewRelativeUrl = SPContext.Current.ViewContext.View.ServerRelativeUrl;
#endregion
------解决方案--------------------
亲 提权需要重新new一个对象,用Context的是不行的
------解决方案--------------------
在RunWithElevatedPrivileges的语句块中添加
using (SPSite site = new SPSite(siteUrl))
{
// ..... Acess the folder from the site in the using block
}