0
votes

I am working with SharePoint 2010. I need to get the data from excel file stored in sharepoint library. I have plans to accomplish this by using OLEDB connection. So I need to download the excel file from doc library and store it in a temporary location and then access this temp file to get data from it. Now my question is which is the best ans safe location to stored the downloaded file? So far I have used SharePoint's layouts directory, C:windows:TEMP and even Path.GetTempFileName(). But the result I get this is " ACCESS DENIED!". Any ideas in temporary location? Is there any other location which is safe?

Thanks

1

1 Answers

1
votes

Check whether you are running the file saving code with Run with elevated privileges and the app pool account has write access to the provided path. It's not a good practice to store temp files inside 14 hive.

Why don't you use Excel Web services to read the excel file if your farm has excel services enabled. Refer http://msdn.microsoft.com/en-us/library/ms500767%28v=office.14%29.aspx

Or else try to use third party libraries like EPPlus where you can open the excel file using a stream rather than from a physical file location.