Programmatically overwrite an existing file

Does anyone know how to overwrite an existing file in the vault with one from outside the vault in Visual Basic?

I have tried using vault.GetFolderFromPath.AddFile("C:\test.txt") which works great for new files, but fails with return code: E_EDM_NAME_ALREADY_EXISTS.

I think my solution may involve IEdmCallback6::Resolve, mlLongData2 = 1 (Edmra_Replace) but I can’t' figure how to use it.

SolidworksSolidworks Pdm enterprise Pdm