Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.