Custom C# application failure on check in

I am writing an application to rename, move, checkout, update file card properties and then check a group of files in based on location. I have the bulk of the application working but when I go to check the files in I get an error "An attempt was made to access a file that is exclusively opened by another application". I am lost I have tried nulling the the vault and loging back in, but that will not work. ideas?

SolidworksSolidworks Pdm enterprise Pdm