When you address a file in your application just with File-Name (like 'Scene1.bmp') your application will search for the file on the path of your application exe file as Default-path of your application, but Default-Path may be changed for some reasons, you can set the Default-Path of your application with SetCurrentDir
function and get Default-Path with GetCurrentDir
function
Every Process has a "Current Directory" as Default-Path and it is changeable, so you should always work with full address of the file you want to use
You can get Full-Path of exe file of your application from ExeName
field of Application
Class :
var
MyApplicationFullPath : String;
begin
MyApplicationFullPath := Application.ExeName;
end;
With ExtractFilePath
function you can get the Path without File-Name of your application exe file, in fact address of folder of exe file and then you can use this address to work with files are besides of your exe file, for example :
Image1.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'Scene1.bmp')
You can be sure that 'Scene1.bmp' will be found and Default-Path of your application doesn't matter
HOW CAN I EXACTLY KNOW WHERE THE IMAGE'S PATH
Application's Current Directory + 'Scene1.bmp' :
ImageFullAddress := GetCurrentDir + 'Scene1.bmp'
ProgramData
subfolder. Search SO or MSDN for details about this. F.ex. this – Tom BrunbergProgramData
folder. Take a look atShGetFolderPath
or similar functions to find out where that is. You can also store them in the program directory. – Rudy VelthuisScene1.bmp
? – Free Consulting