Page 1 of 1

Setting default directory of OpenFileRequester

Posted: Mon Oct 15, 2007 10:45 pm
by JElliott
I'm trying to figure out to change the default directory for OpenFileRequester to point to the directory of the previously opened file (assuming there has been a previously opened file). This is a fairly common behavior and saves a great deal time when loading several files. I can't figure out how to capture the path of the file when I navigate to it via OpenFileRequester. I've tried GetCurrentDirectory() but obviously it is not influenced by OpenFileRequester. I have searched and searched but not found a solution.

Any insight would be greatly appreciated thanks.

Jeff

Posted: Mon Oct 15, 2007 10:48 pm
by Derek
Have you looked at the output when you select a file?

Code: Select all

Debug OpenFileRequester("","","",0)
From the manual:
The returned 'FileName$' can be easily split into file, path and extension string with the following functions: GetFilePart(), GetPathPart() and GetExtensionPart().

Posted: Mon Oct 15, 2007 10:56 pm
by #NULL
we just had such a question in the german forum.
under windows the Open/SaveFR do automaticly open in the last used (not canceled) directory. they use both the same. but of course you must specify a filename without a path as parameter 'defaultfile$', otherwise that path is used.
or you can do it like that

Code: Select all

def_file.s = "C:\lalalalalalala"
Repeat
  file.s = OpenFileRequester("title", def_file, "*.*|*.*",0)
  If file
    def_file = file ; or 'GetPathPart(file)' if you wish
  EndIf
  Delay(500)
Until 0

Posted: Tue Oct 16, 2007 12:06 am
by JElliott
Thanks to you both Derek and #Null - exactly what I was missing - I looked at every other file related command except the obvious :oops:

Posted: Tue Oct 16, 2007 3:51 pm
by Derek
No problem, glad I could help. :)