title: c# clearcase: How to edit file then check it out and then check it in with the saved changes?
body: <p>I am trying to programattically edit a checked in file, then check it out and save the changes made while it was check in.  And then check it back in with the saved changes:
  Edit -> CheckOut -> Save -> CheckIn</p>
  
  <p>When attempting to save, I am running into a problem that the file does not recognize itself in the folder and thinks its attempting to overwrite another file.</p>
  
  <pre><code>    void checkOut(string sourcefile)
      {
          ClearCase.CCElement element = m_CC.get_Element(sourcefile);
  
          if (element != null)
          {
              ClearCase.CCVersion latestVersion = null;
              FileInfo fi = new FileInfo(sourcefile);
  
              latestVersion = element.get_Version();
              if (latestVersion != null)
              {
                  ClearCase.CCBranch branch = latestVersion.Branch;
                  ClearCase.CCCheckedOutFile file = latestVersion.CheckOut(ClearCase.CCReservedState.ccReserved, "", false, ClearCase.CCVersionToCheckOut.ccVersion_SpecificVersion, true, false);
                  string path = file.ExtendedPath;
              }
          }
      }
  
      void checkIn(string sourcefile)
      {
          ClearCase.CCElement element = m_CC.get_Element(sourcefile);
          element.CheckedOutFile.CheckIn("", true, sourcefile, ClearCase.CCKeepState.ccRemove);
      }
  
  
      void excelEdit()
      {
        string fileName = Globals.ThisAddIn.Application.ActiveWorkbook.Name;
  
        //EDIT EXCEL FILE from (fileName)
  
        checkOut(fileName);
        Globals.ThisAddIn.Application.ActiveWorkbook.SaveAs(fileName);
        checkIn(fileName);
      }
  </code></pre>