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
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.
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);
}
That’s not the process you would use if you were doing it manually and not the way I’d recommend to do it programmatically.
You should CHECK OUT the file first (which will make it writeable on disk), EDIT it, SAVE it, then CHECK it back IN (which will make it read-only on disk).
You may think that in Visual Studio you start editing before you check out, but in reality, Visual Studio will check the file out when you start to edit.