I was trying to open an Excel file programmatically in my .NET web application. I used the code in one my previous posts. Unfortunately, I found myself struggling with this hair-pulling issue:
Microsoft Office Excel cannot access the file ‘c:\file.xlsx’. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.
As it’s stated here, follow these 2 easy steps. Then you can go back to your normal life!
- Create directory
C:\Windows\SysWOW64\config\systemprofile\Desktop(for 64 bit Windows) or
C:\Windows\System32\config\systemprofile\Desktop(for 32 bit Windows)
- Set full control permissions on Desktop directory above (for example in Win7 > IIS 7 > DefaultAppPool: set permissions for user