While trying to resolve a much uglier and more complicated problem, I have discovered that ModelDoc2::ForceReleaseLocks and its companion method ModelDoc2::ReloadOrReplace do not properly manage the temporary lock (tilde) files associated with the model. Consider the following simple C# macro:
This code simply releases the locks on an open part file, renames the file by prepending it with 'A' and then reloads the new model. What I have found is that the tilde file for the original part file is never deleted. For instance, if I open a file named A.sldprt, a tilde file is created named ~$A.sldprt. After the macro is run, there are now two tilde files: ~$A.sldprt and ~$AA.sldprt. This rogue tilde file will persist even after closing all documents and even after closing SW itself. With a name like ForceReleaseLocks, you would think that deleting the lock file would be one of its primary functions.
I do have the exact same problem. I tried different things to get rid of it, but the handle on the original file is gone after I use ReloadOrReplace so I cannot do anything on that tilde file either with EPDM API OR SolidWorks API.