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);
}