title: Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'
body: <p>I have my code as follows :-</p>
  
  <pre><code>Microsoft.Office.Interop.Excel.Application oXL = null;
  Microsoft.Office.Interop.Excel.Sheets sheets;
  Application excel = new Microsoft.Office.Interop.Excel.Application();
  
  
  excel.Workbooks.Add(System.Reflection.Missing.Value);
  
  /*
      * Here is the complete detail's about Workbook.Open()
      * 
      *  Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, 
      *  Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin,
      *  Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
      */
  
  Workbook workbook = excel.Workbooks.Open(
      System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Template.xlsx"),
      Missing.Value, true, Missing.Value, Missing.Value,
      Missing.Value, Missing.Value, Missing.Value,
      Missing.Value, Missing.Value, Missing.Value,
      Missing.Value, Missing.Value, Missing.Value,
      Missing.Value);
  sheets = workbook.Worksheets;
  </code></pre>
  
  <p>Now for the line :-</p>
  
  <pre><code>workbook = excel.Workbooks.Open(
      System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Template.xlsx"),
      Missing.Value, true, Missing.Value, Missing.Value,
      Missing.Value, Missing.Value, Missing.Value,
      Missing.Value, Missing.Value, Missing.Value,
      Missing.Value, Missing.Value, Missing.Value,
      Missing.Value);
  </code></pre>
  
  <p>It gets executed directly from the visual studio (F5) but when i try to access it with IIS it wont work.
  Throws error as follows:-</p>
  
  <blockquote>
    <p>Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'. There are several possible reasons:<br/>
    • The file name or path does not exist.<br/>
    • The file is being used by another program.<br/>
    • The workbook you are trying to save has the same name as a currently open workbook.<br/></p>
  </blockquote>
  
  <p>I have tried the work around as:-</p>
  
  <blockquote>
    <ul>
    <li>Folder and the file exist, giving access to the IUSR_### (IIS user) and to the ASPNET user in the folder where the file is.<br/>
    
    <ul>
    <li>At Component Services(DCOM) given access to appropriate user.</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>I have already given all permission's to the folder where the template(.xlsx) exists</p>
  
  <p>Any suggestions??</p>