1

Can anyone help me in below issue?

My code below, is trying to access a document library from a site collection. At a below line (SPFolder docLibrary = oweb.Folders[strOriginalDocLibName];) its giving me an error like, {"0x80070005Access denied."}.

Can anyone let me know what is causing this error? and if anyone has a solution to it?

its on my local environment and I have full control over the site collection.

public static void FunctionMetadataUpdation(string strSiteUrl, string strDocLibName, string strFuncName) {

        try
        {
            Logging.InsertLog("In FunctionMetadataUpdation function ", false, strFuncName);
            #region Updating Metadata for all the Functions of PT


            using ( SPSite oSite = new SPSite(strSiteUrl))
            {

                using (SPWeb oweb = oSite.OpenWeb())
                {
                    string strOriginalDocLibName = "";
                    if (strFuncName.Equals("PM"))
                    {

                        strOriginalDocLibName = "Program Management";
                    }
                    else
                    {
                        strOriginalDocLibName = strDocLibName;
                    }

                        ***SPFolder docLibrary = oweb.Folders[strOriginalDocLibName];***                        
                        SPList lst = oweb.Lists[strDocLibName];                       

                    try
                    {
                        foreach (SPFolder folder in docLibrary.SubFolders)
                        {
  • Have you tried running the code as elevated? – Amal Hashim Mar 26 '15 at 13:19
  • Thanks... it worked. I was not knowing how to use elevated function. I googled it and applied. – SP_Tech Apr 1 '15 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.