Microsoft Excel无法访问ASP.net项目中的文件

我创build的Web应用程序,每行读取Excel文件,当我从我的本地运行它完美的工作。 但是当我部署到Web服务器[赢得7 64位],它会产生这样的错误:

Microsoft Excel cannot access the file 'C:\TestReadExcel\testdata.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. 

这个错误来自这个代码(我使用Microsoft.Office.Interop.Excel):

 Line 195: Dim workbook = xlApplication.Workbooks.Open(fileName) .. .. 

我已经尝试过各种方法:

  1. add folder **desktop** C:\Windows\System32\config\systemprofile\ and in C:\Windows\SysWOW64\config\systemprofile -it not working 2. add security account for network services and iis_iusrs in DCOM config - microsoft excel application (allow all) - it not working 3. already restart my web server after i configured step 1-2 , and still not working 4. already test to add security account full control in folder C:\TestReadExcel\ , and still not working 

还有什么我需要做的解决这个问题? 或者有什么比使用interop excel有什么办法?

需要你的帮助谢谢你。

使用Server.Mappath来获取文件path。 并确保IIS_User已经读取了放置Excel文件的文件夹的权限。