Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ

Usefull Functions & Procedures

Another GETDIR() alternative (to see the entire network) by Mike Gagnon
Posted: 21 Apr 02

LPARAMETERS cDialogTitle, cStartingFolder, nBrowseFlags
*  Select a directory using the default browser dialog
*  Give a default title if none specified
IF TYPE('cDialogTitle') # 'C'
    cDialogTitle = 'Please select a folder:'
*  Default the start folder to an empty string;  if
*  you specify a starting folder, the browse is
*  anchored there, although you can override it with
*  the dialog's EditBox
IF TYPE('cStartingFolder') # 'C'
    cStartingFolder = ''
IF TYPE('nBrowseFlags') # 'N'
    * uses BROWSEINFO structure ulFlags values
    * by default, set BIF_RETURNONLYFSDIRS (1) and BIF_EDITBOX (16) and BIF_VALIDATE
    * to limit to returning directories, provide an edit box to let user enter a path,
    * and validate manually-entered paths
    * ulFlags values:
    *    BIF_STATUSTEXT            4
    *    BIF_EDITBOX                0x10
    *    BIF_VALIDATE            0x20
    *    BIF_BROWSEFORCOMPUTER    0x1000
    *    BIF_BROWSEFORPRINTER    0x2000
    nBrowseFlags = 32 + 16 + 1
LOCAL oBrowseObject, cPathToReturn, oShellObj
oShellObj = CREATEOBJ('Shell.Application')
cPathToReturn = ''
*    Get a Folder object
oBrowseObject = oShellObj.BrowseForFolder(0, ;
        cDialogTitle, ;
        nBrowseFlags, ;
*    Before I used the Items collection of the Folder object
*    to get a path;  it doesn't work if the directory is empty.
*    Instead, spin through the Items collection of the Parent
*    Folder and locate the item whose name matches the
*    Title property of the Folder object;  return that path
IF TYPE('oBrowseObject') = 'O' AND ! ISNULL(oBrowseObject)
    FOR EACH item IN oBrowseObject.ParentFolder.Items
        IF item.name == oBrowseObject.title
            cPathToReturn = Item.Path
RETURN cPathToReturn

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close