Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getfile() from folder n 4

Status
Not open for further replies.

webmonger

Programmer
Mar 13, 2004
66
AU
I would like to have getfile() open on the 'My Documents' folder the first time then on every other use to the previously chosen folder.

Can I save the current value to a file then read it in again?

Thanks

Webmonger
 
webmonger

How can I select multiple files from Windows faq184-3106

utilises the Windows common dialog as opposed to GETFILE().

It has a property .cInitialDirectory which you can use to set where the dialog opens, and returns the path to the selected file(s) as .cFilepath.

You can save .cFilepath to TABLENAME.field and then use TABLENAME.field as the value for .cInitialDirectory.

You can do the same basic idea with GETFILE() but the Windows common dialog has a lot more to offer, IMHO.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.com
PDFcommandertm.co.uk


 
Hi

The problem in using c:\my documents
is that this need not be that special folder. For example XP keeps in a different place.

I would suggest Mike Gagnons code.. and allow users to browse to special folders as well.
***********************************
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
ADD OBJECT olecontrol1 AS olecontrol WITH ;
Top = 24, ;
Left = 48, ;
Height = 169, ;
Width = 241, ;
Name = "Olecontrol1" ,;
OleClass = "Shell.Explorer.2"
ADD OBJECT command1 AS commandbutton WITH ;
AutoSize = .T., ;
Top = 216, ;
Left = 120, ;
Height = 27, ;
Width = 114, ;
Caption = "Get folder content", ;
Name = "Command1"
PROCEDURE Init
this.olecontrol1.oBJECT.Navigate2("c:\")
ENDPROC
PROCEDURE command1.Click
LOCAL cDir
cDir = GETDIR('','','',2)
thisform.olecontrol1.navigate2(cDir)
ENDPROC
ENDDEFINE
** - Mike Gagnon

____________________________________________
ramani - (Subramanian.G) :)
 
Webmonger,

Ramani rightly pointed out:

The problem in using c:\my documents
is that this need not be that special folder. For example XP keeps in a different place.


So, I'll amend my code to take that into account:


lcOldDir = SYS(2003)
oWsh = CREATEOBJECT("wscript.shell")
lcMyDocs = oWsh.SpecialFolders("MyDocuments")
&& Note no space in MyDocuments
SET DEFAULT TO "&lcMyDocs"
? GETFILE() && Opens in My Documents
SET DEFAULT TO "&lcOldDir"
? GETFILE() && opens in previous folder


Mike



Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top