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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening a directory

Status
Not open for further replies.

filipe26

Programmer
Mar 17, 2003
152
PT
hi how can i open or explore through a simple click button a directory?
 
Put a TOpenDialog component on your form, and change any parameters to the file types you want, the title of the dialog etc. There are a range of options to set as well.

Then with a suitable buttons OnClick event:
[tt]
procedure TF_Main.B_open_errorClick(Sender: TObject);

begin
OpenDialog.InitialDir := MyDir; // set your path
OpenDialog.FileName := ''; // your initial file mask
OpenDialog.FilterIndex := 1; // you can have multiple extension mask
// this uses the first (not zero based)

if OpenDialog.Execute then // execute the dialog
begin
if not (ofExtensionDifferent in OpenDialog_errors.Options) then
begin
{do something here with the default extension}
end
else
begin
{do something if a different extension}
end
end //if OpenDialog
end;
[/tt]
There is of course help for that component.

Cheers

Chris ;-)
 
but i dont want a dialog box ,i just want to open a certain directory simple by clicking a button.
 
Try the FileExists function - that allows you to look at a specific directory and file.

There are a whole swag of file management routines in the SysUtils unit.

BTW, your question sounded like you wanted a file list (ie explore)


Chris ;-)
 
No, fileexists its another thing.What im trying to do is through windows API open a directory.
 
Do you mean change directory (like the old DOS CD command)?
Please try and explain the problem in more detail.

Chris ;-)
 
do you know kazza lite ??You have a button that opens "my shared folder".What im trying to do is the same but with another folder.
 
I don't know Kazza - but this sounds like a version of Windows Explorer, where you open select a directory and it displays the contents, or the My Documents button in Office apps. Am I getting closer to what you mean?

Don't know of a specific WinAPI function, but you could do the same with FindFirst and FindNext and fill a string grid with the contents. There is an example of this in the FindFirst help

Chris ;-)
 
The WinSDK help that ships with D7/D8 may contain some more information - I've only ever come across low level functions similar to FindFirst/FindNext

Chris ;-)
 
Just ShellExec() the full path, like you would type it in the Start/Run command...;-)

HTH
TonHu
 
Hi.

If you use Delphi6 or Delphi7 you can use TShellListView from the Samples palette.
Set root path where you like... works like Windows Esplorer.

Cheers,
mha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top