I need to keep some data/files inside the layouts folder. My SharePoint project is "MyProject" Hence the directory structure includes
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\MyProject"
Now I need to programmatically create a new folder called "Data". But I get "Access Denied" error.
SPSecurity.RunWithElevatedPrivileges(delegate
{
String path = SPUtility.GetGenericSetupPath(String.Empty) + "TEMPLATE\\LAYOUTS\\MyProject\\Data";
bool IsExists = System.IO.Directory.Exists(path);
if (!IsExists)
System.IO.Directory.CreateDirectory(path);// Access denied!
});
Can anyone tell me why I am getting the access denied ? even though I have wrapped my code inside RunWithElevatedPrivileges?