How do I know the path to the file in the Blender Game Engine? In BGE, in an initialization script, I have these instructions:

var=bge.logic.expandPath("//")
print("====== path=",var,"=======")


and now the variable "var" is set to the path of the Blender file.

Ok, but when I export the game (Save As Game Engine Runtime) and move the saved file to another path or another PC, the "var" variable does not change, i.e. it remains the one it was before moving the file.
Have you looked at the right console?

You need to start the game with option -c to see the console window of the game.

When you do not see the game's console you might have looked at the console of the still opened Blender.

In my test the path was correctly pointing to the location of the game's folder.