mfleeming
(Lurker)
2002-10-21 01:55 AM
Can I use OpenFileDialog to select folders

I can select files, but would like to return a folder path even if the folder is empty.

Is this possible?


Chris S.
(MM club member)
2002-10-21 02:28 PM
Re: Can I use OpenFileDialog to select folders

If you just want to browse for folder, use this...

code:
$objShell = CreateObject("Shell.Application")
$objFolder = $objShell.BrowseForFolder(0, "Select a folder:", 0)
$objFolderItem = $objFolder.Self
? $objFolderItem.Name
? $objFolderItem.Parent
? $objFolderItem.Path
? $objFolderItem.Size
? $objFolderItem.Type



mfleeming
(Lurker)
2002-10-21 07:52 PM
Re: Can I use OpenFileDialog to select folders

Wonderful, Sir, thank you.

Whilst we're on a winning streak, can I also ask if it can be seeded by a currently selected folder (say from an ini file)?

Also, where would be a good place to get some idea of other objects I can use? I usually program in a 4GL business language so I'm not familiar with Windows programing.


Sealeopard
(KiX Master)
2002-10-21 07:54 PM
Re: Can I use OpenFileDialog to select folders

In general, the MSDN documentation will contain everything regarding scriptable object. It also contains a plethora of examples.

Chris S.
(MM club member)
2002-10-21 08:46 PM
Re: Can I use OpenFileDialog to select folders

The short answer is, yes.

code:
$objFolder = $objShell.BrowseForFolder(0, "Select a folder:", 0, "c:\archive")

Doing this, however, makes this item the top level in your browser tree. I.E. They can browse below, but not above your default directory. Could be a good thing, depending on how you want to use it. [Big Grin]


Radimus
(KiX Supporter)
2003-01-09 12:47 AM
Re: Can I use OpenFileDialog to select folders

This is returning nothing for me on XP...
code:
 	$objShell = CreateObject("Shell.Application")
$objFolder = $objShell.BrowseForFolder(0, "Select a folder:", 16384)
$objFolderItem = $objFolder.Self
$selectedfile = $objFolderItem.Path
Status($objFolderItem.Name)
Status($objFolderItem.Parent)
Status($objFolderItem.path)
Status($objFolderItem.type)
Status($selectedfile)

Status() is a function for dumping the info to a kixform listbox (yes the function works...)

Any help?

[ 09. January 2003, 00:48: Message edited by: Radimus ]


Radimus
(KiX Supporter)
2003-01-09 12:54 AM
Re: Can I use OpenFileDialog to select folders

ahhhh... it will return infor for folders but not files..

dammit^2


ShawnAdministrator
(KiX Supporter)
2003-01-09 02:40 AM
Re: Can I use OpenFileDialog to select folders

Rad - FileOpenDialog() could be thought of as like a BrowseForFile() function ?

$FileName = $Form.FileOpenDialog("Open", ".\", "", "", 0)

[edit] crap but then you would have to parse-out the returned string i guess.

-Shawn

[ 09. January 2003, 02:43: Message edited by: Shawn ]


Radimus
(KiX Supporter)
2003-01-09 03:12 AM
Re: Can I use OpenFileDialog to select folders

that is what I had to do anyway...

This works perfectly...

Thanks Bud


Radimus
(KiX Supporter)
2003-01-09 03:32 AM
Re: Can I use OpenFileDialog to select folders

BTW... what are the parameters for $Form.FileOpenDialog("Open", ".\", "", "", 0)

ShawnAdministrator
(KiX Supporter)
2003-01-09 04:12 AM
Re: Can I use OpenFileDialog to select folders

Good news - this is from KIXLIST.DOC available from Kixforms.org:

quote:

FileOpenDialog ( String Title, String Directory, String Filename, String Filters, Number Flags ) as String

FileSaveDialog ( String Title, String Directory, String Filename, String Filters, Number Flags )

Display the system "File Open" and “File Save” dialog box.

Title - The title of the dialog box.

Directory - The default directory that you want to use when the dialog is displayed.

FileName - The default filename that you want to appear when the dialog is displayed.

Filters – User defined string of filters that can limit the files displayed. For example:"Bitmaps|*.bmp|All Files|*.*"

Flags – One or more of the following flags specifying how to create the file dialog box.

Returns a string specifying the selected or file, or NULL if no file selected.

Never didn't finish the flags parm but just set it to zero. Chris S. was kind enough to document a much better version of above but it hasn't been published yet.

-Shawn

[ 09. January 2003, 04:13: Message edited by: Shawn ]


Chris S.
(MM club member)
2003-01-09 03:04 PM
Re: Can I use OpenFileDialog to select folders

Rad, you have mail. [Smile]

Radimus
(KiX Supporter)
2003-01-09 03:22 PM
Re: Can I use OpenFileDialog to select folders

thank you sir.

This was Exactly what I needed.

$FileName = $Form.FileOpenDialog("Find engine.exe Update", ".\", "", "SuperDat|*eng.exe", 0)