Solved

Path Dialogs

Posted on 1998-07-30
25
308 Views
Last Modified: 2010-04-04
Can anyone tell me how to get a "Open File Dialog" to get the path only?

I need to make a dialog where the user must select a path only.
0
Comment
Question by:jconde
  • 11
  • 8
  • 6
25 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 10 total points
ID: 1359234
Like this....

OD - Open File Dialog
------------
var Path : string;
begin
  Path := ExtractFilePath(OD.Filename);
end;  
----------
That's all...

Regards,
Viktor Ivanov
0
 
LVL 7

Author Comment

by:jconde
ID: 1359235
Thats right viktor, but I need to choose a file in order to run the extractpath fuction!  I just want to select a path from the dialog box.

jorge
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359236
I'm not sure what you need...Would you please explain it again... Thanx...

Regards,
Viktor Ivanov
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Expert Comment

by:viktornet
ID: 1359237
You mean you have a listbox or something with the paths of some files, and when you select a path from there you want something to happen? Is that what you want?

Regards,
Viktor Ivanov
0
 
LVL 7

Author Comment

by:jconde
ID: 1359238
Viktor:

What I want to do, is to open up the dialog box, and then select a folder (directory) only.  What I don't want to do, is to have to select a file and then extract the path out from it.

Or, do you suggest any other way of accomplishing this task?...I'll say again, I don't want to select a file, I want a path only.  (when you click in a folder, the folder opens, and expects you to select a file....that's what i want to avoid)

bye
jorge
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359239
What you can do is when the Open Dialog execute, even if the user selects a file and press open, then you don't write any code for opening files or anything...Just write the procedure I gave you above to extract the path...when I say path I mean the path to the last sub folder without the name of the file selected...Maybe what I just wrote sounds a little nonsense, but if you want me to write a fast demo for I will, just leave a comment with your e-mail address...Talk to you later...

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359240
Well, I already wrote a demo, so if you want to see it just leave a comment telling me your e-mail address so I can send you the source code...

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359241
There is actually another way which is not maybe the best one...This way is to actually set the DefaultExt property to have a value that doesn't exist in the system....like...

DefaultExt := '*.sss'; this will prevent the opend dialog to show files and there will be only directories...

Regards,
Viktor Ivanov
0
 
LVL 3

Expert Comment

by:vladika
ID: 1359242
function SelectDirectory(var Directory: string; Options: TSelectDirOpts; HelpCtx: Longint):Boolean;

From help:
Calling the SelectDirectory function displays the Select Directory dialog box.

Detail see in help.

If it help I hope you do not forget about points :-)

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359243
It's the same thing wethere you choose this OldStyle file dialog box or the official Dilaog Box...It still displays the files.....If you need a specific name of directory you can use ... DirectoryExists...or what you could do is use TSearchRec....with FindFirst, FindNext...and a flag 'faDirectory', which will return all subdirectories in a specified directory....

Regards,
Viktor Ivanov      
0
 
LVL 3

Expert Comment

by:vladika
ID: 1359244
When you use OpenDialog user must select file.
When you use SelectDirectory user must select only path.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359245
Ain't it the same? You can extract the path from the file though, what you can also do is to change the style of the Open Dialog and it will still be the same as the Directory Dialog :), anyway...As I was making research I saw this TFolderBrowse(not sure for the name)component that is exactly what you need... I think I saw it on Torry's Pages...I'm not sure ...Gotta find it somehow....Talk to ya later guys...

Regards,
Viktor Ivanov
0
 
LVL 3

Expert Comment

by:vladika
ID: 1359246
> Ain't it the same? You can extract the path from the file though.

It is not the same.
When you use OpenDialog user MUST SELECT FILE.
What will you do if the directory is empty (no files)?
How do you select this directory?


0
 
LVL 7

Author Comment

by:jconde
ID: 1359247
Thats the point vladika, I don't want the user to select any files!
0
 
LVL 7

Author Comment

by:jconde
ID: 1359248
Can you tell me how to do that please vladika or viktor?

thanx

jorge
0
 
LVL 7

Author Comment

by:jconde
ID: 1359249
Can you tell me how to do that please vladika or viktor?

thanx

jorge
0
 
LVL 3

Expert Comment

by:vladika
ID: 1359250
Excuse me, I do not understand.
Are you try to use SelectDirectory function?

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359251
Vladika: He needs a Dialog that would display only directories with no files...Like when you go to Start/FindFiles/Browse/...(that's in Windows, not in Delphi)  and it will display only the dirs, and subdirs, without files....I think that's what he is looking for....

Regards,
Viktor Ivanov
 
0
 
LVL 3

Expert Comment

by:vladika
ID: 1359252
As Victor say there are many freeware components for this task.
I try TBrowseFolder, TBrowseDialog, TBrowseDirectoryDlg from torry's page (www.torry.ru)
All components with source (you can learn it).
It works fine. Try to use it.

0
 
LVL 3

Expert Comment

by:vladika
ID: 1359253
O, SORRY!!!
Viktor

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359254
Vladika: Sorry about what???

Regards,
Viktor Ivanov
0
 
LVL 3

Expert Comment

by:vladika
ID: 1359255
I wrote ViCtor. Sorry.


0
 
LVL 10

Expert Comment

by:viktornet
ID: 1359256
Don't worry about that...Actually my name is spelled Victor, but in my passport it is written Viktor . That's the reason I use Viktor instead of Victor...Friends???

Regards,
Viktor Ivanov
0
 
LVL 3

Expert Comment

by:vladika
ID: 1359257
O'key
0
 
LVL 7

Author Comment

by:jconde
ID: 1359258
Thank you both, I got it working!

regards,
jorge
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using idhttp to login to instagram 2 106
find a node in VST 2 73
Delphi: making a BW image transparent 10 60
Slow Restore if incremental backups using RDiff.exe 4 30
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question