To preserve the 'last directory' within a program session store the path in a string variable.

To preserve it from one session to the next store the contents of the string variable to a file when the program ends and load it back from the file when the program starts.