Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getfile in another directory other than home
Message
From
11/01/2017 04:31:22
 
 
To
10/01/2017 19:03:30
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01646483
Message ID:
01646494
Views:
80
Likes (2)
locfile() is a good solution.this is some suggestions around.

0.getfile() dont open files in home() as you said directory but in current dir

1.getfile() is a vfp dialog opening files but it works programmatly only in one current directory.
GETFILE() will always start at the default directory.
manually,can navigate into directories inside this dialog box only.
then if you dont want to use chdir "CD" ,fix the initial dir and choose any goaled dir.when done return to your initial dir.
local m.x,lcfilename,mynewFolder
m.mynewFolder=home(1)
m.x=sys(5)+sys(2003)   &&current dir
set defa to (m.mynewfolder  )
m.lcfilename=getfile("app")  &&any extension
messagebox(m.lcfilename)
set defa to (m.x)
2. the showOpen standard windows dialog box to open file(mscomdlg.commondialog class activeX) have the same behavior.vfp one is maybe derived from.
loComDialog = createobject("mscomdlg.commondialog")
with loComDialog
.Filter = "All Files (*.*)|*.*|Text Files(*.txt)|*.txt|Batch Files (*.bat)|*.bat"
.MaxFileSize=100
.ShowOpen()
MESSAGEBOX(.FileName)
endwith
3.you can tweak the vfp getdir() (folder browse dialog) function to handle as well the files.
its done with the 16384 flag
GETDIR([cDirectory [, cText [, cCaption [, nFlags [, lRootOnly]]]]])
if you set nFlag to 16384 the files can be returned but vfp team dont finish the work here.the file is returned like a directory with a "\" at the end.
note you can specify any folder or restrict the search to any folder (set in the getdir(...).
local lcfilename
lcfilename=getdir(home(1),"open filename ","browse for filenames/folders",16384)
if not empty(m.lcfilename)
m.lcfilename=substr(m.lcfilename,1,len(m.lcfilename)-1)
messagebox(m.lcfilename)
endi
*update: can use also : JUSTPATH(m.lcfilename)
update: for whose can use scripts there many good solutions of VBScript File Browser in :
https://gist.github.com/mlhaufe/1034241
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform