Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Folder not creating in Layouts folder in sharepoint

$
0
0

I written the code to create the folder in Layouts folder automatically. Code was running good in my local server. But when i run in our QA server folder not creating . I have given the RunwithElevatedPrivilizes, but no result in QA Server.

below is my code:

---------------------------------------

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            
            SPWebApplication webApp = (SPWebApplication)properties.Feature.Parent;         
            
            try
            {

                string strWebAppName = webApp.Name.ToString();                              
              
              SPSecurity.RunWithElevatedPrivileges(delegate()
                      {
                          if (Directory.Exists(strLayoutsDestination))                      
                          {
                              string strWebAppNameFolder = strLayoutsDestination + strWebAppName;
                              if (!Directory.Exists(strWebAppNameFolder))                     
                              {
                                  string newPath = Path.Combine(strLayoutsDestination, strWebAppName);
                                  Directory.CreateDirectory(newPath);                          
                                  string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
                                  string destFile = System.IO.Path.Combine(newPath, fileName);
                                  System.IO.File.Copy(sourceFile, destFile, true);                  
                              }
                              else
                              {
                                  return;
                              }

                          }
                      });
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }


            webConfigMod(true, webApp);
        }


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>