In Delphi, I need to rename file that is in use by several users across the network. I can rename it from Windows explorer, but can not from Delphi using TFile.Move or RenameFile. In Delphi documentation I found that these functions are wrappers around Windows API MoveFile. File remains in the same drive and directory, so there is no problem with MoveFile constrains.
RenameFile(OldFileNameWithoutPath, NewFileNameWithoutPath);
My use case is installing new version of my program, I download new exe file from ftp, then to rename existing and running exe file, and finally rename exe file downloaded from ftp to standard name. From command promomt renaming part would be:
ren Izbori.exe IzboriOld.exe
ren IzboriNew.exe Izbori.exe