I'm working with SharePoint 2010 Webparts. I have created a document library in SharePoint. I have uploaded an excel file inside this doc library. I need to store this Excel file inside a temporary folder inside layouts folder of sharepoint root directory using the code below.
SPSecurity.RunWithElevatedPrivileges(delegate
{
String tempPath = SPUtility.GetGenericSetupPath(String.Empty) + "TEMPLATE\\LAYOUTS\\SampleWebPart\\Files";
bool IsExists = System.IO.Directory.Exists(tempPath );
if (!IsExists)
System.IO.Directory.CreateDirectory(tempPath );// access denied
});
Can anyone tell me why the folder tempPath cannot be created ? How can this be resolved?
Thanks