title: Error message: You don't have permission to open this file. Contact the file owner or an administrator to obtain permission
body: <p>I have a windows forms application which opens two excel files and compare the cell content.</p>
  
  <blockquote>
    <p>Recently I'm experiencing the following error in some machines that
    this application is installed in.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/I2saL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I2saL.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>In other machines this works perfectly fine.</p>
  </blockquote>
  
  <p>I've checked folder permissions / file permissions / Excel and Windows versions of the machines that runs this program. Nothing seems to work for me and sort out the problem as a whole. </p>
  
  <p>I'm using Microsoft.Office.Interop.Excel for reading and writing to my excel files.</p>
  
  <p>To open the excel files I'm using the following code. </p>
  
  <pre><code>        bool inputSheetReadStatus = false;
          DialogResult dialogResultInputSheet = openFileDialog_InputSheet.ShowDialog();
  
          if (dialogResultInputSheet == DialogResult.OK)
          {
              InputSheetFullPath = openFileDialog_InputSheet.FileName;
              InputSheetFileName = openFileDialog_InputSheet.SafeFileName;
              InputSheetFilePath = Path.GetDirectoryName(InputSheetFullPath);
  
              try
              {
                  Excel.Application xlApp_InputSheet = new Excel.Application();
                  Excel.Workbook xlWorkbook_InputSheet = xlApp_InputSheet.Workbooks.Open(InputSheetFullPath);
                  Excel.Worksheet xlWorksheet_InputSheet = xlWorkbook_InputSheet.Sheets["CO"];
                  Excel.Range xlRange_InputSheet = xlWorksheet_InputSheet.UsedRange;
  
                  string InputSheetDocumentValidationStringValue = xlRange_InputSheet.Cells[cosv.InputSheet_CO_Style_Label_Row, cosv.InputSheet_CO_Style_Label_Col].Value2.ToString().Trim();
  
                  if (InputSheetDocumentValidationStringValue.ToUpper() == cosv.InputSheet_CO_Validation_String)
                  {
  
                  // If valid excel file the manipulation logic goes here
  
                  }
               }
              catch(Exception Ex)
              {
              }
           }
  </code></pre>
  
  <p>Any thoughts or ideas for me to try out in order to overcome this issue? Thanks in advance.</p>
  
  <p>I tested this application in <strong>Windows 7 / 8 / 10 machines with excel versions 16 and 17</strong> using the <strong>same two files</strong>. Out of the <strong>10</strong> machines I tested this, in <strong>4 machines my application worked</strong>. In <strong>6 machines my application displayed this error message</strong>.  </p>