title: Getting error on calling SaveAs method
body: <p>I'm trying to create a csv file from an excel file using MS Excel Interop in my C#/Winforms app.</p>
  
  <p>Am getting this error on SaveAs method in the code below.</p>
  
  <blockquote>
    <p>'The file could not be accessed. Try one of the following:</p>
    
    <p>• Make sure the specified folder exists.  • Make sure the folder that
    contains the file is not read-only.  • Make sure the file name does
    not contain any of the following characters:  &lt;  >  ?  [  ]  :  | or 
    *  • Make sure the file/path name doesn't contain more than 218
    characters.'z</p>
  </blockquote>
  
  <p>I tried setting readonly to false in Workbook's Open(...)  method as per:
  <a href="https://stackoverflow.com/questions/2574722/problem-saving-excel-file-after-inserting-data">Problem saving excel file after inserting data</a> , but still getting the same error.</p>
  
  <p>In my code, the csv file path was:C:\
  If I change the csv file path to C:\SomeFolder or some shared UNC path, then I dont get this error.</p>
  
  <p>Please advise.COuld there be some permissions issues with C drive?</p>
  
  <p>Heres the code:</p>
  
  <pre><code>xlApp = new Microsoft.Office.Interop.Excel.Application(); 
  xlApp.DisplayAlerts = false;
  xlApp.Visible = false; 
  wbkSrc = xlApp.Workbooks.Open(m_sSrcFil, 
                          Type.Missing, false, Type.Missing, Type.Missing, 
                          Type.Missing, Type.Missing, Type.Missing, Type.Missing, 
                          Type.Missing, Type.Missing, Type.Missing, Type.Missing, 
                          Type.Missing, Type.Missing);
  
  
                  wstSrc = (Worksheet)wbkSrc.Worksheets[sSrcSht]; 
                  //wstSrc.Activate();
  
                  rngWork = wstSrc.Cells.get_Range("H:H", System.Reflection.Missing.Value); 
                  rngWork.NumberFormat = "General";
  
                  dteTmpDate = Convert.ToDateTime(m_sBusDate); 
                  sTmpFileName = m_sSrcFil.Substring(0, m_sSrcFil.IndexOf(".")) + "_" + 
                      m_sUserName + "_" + dteTmpDate.ToString("yyyy_MM_dd") + ".Csv";
  
                  wstSrc.SaveAs(sTmpFileName, XlFileFormat.xlCSV, Type.Missing, 
                      Type.Missing, true, Type.Missing, Type.Missing, Type.Missing, 
                      Type.Missing, Type.Missing);
  </code></pre>