1
votes

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?

1

1 Answers

0
votes

I've tried you code and work well.

There should be something with Window Folder security settings. On my folder I have next users with read/write permissions:

  1. Creator owner - special permissions
  2. System - Full control
  3. WSS_ADMIN_WPG - All but full control and special permissions
  4. Current user (farm admin) - Full control

If nothing helps try to add everyone in read/write access temporary! just to check if it is really security issue!

Hope it helps,

Andrew