I want to be able to open files in Delphi with a Windows GUI where you can scroll through the folders etc. I have already done this with Matlab with a single function that (after selecting the file) returns a string of the path. You could event specify which extension the be shown. Is this kind of function available in delphi and how should I use it.
you can use the TOpenDialog component which is part of the Dialogs unit. you can create in runtime or drop this component from the Dialogs palette.
if you drop the component to your form you can use in this way
OpenDialog1.Filter := 'Only Text files (*.txt)|*.txt';
if OpenDialog1.Execute then
//do you stuff here
or if you create the component in runtime
Var
OpenDialog1 : TOpenDialog;
begin
OpenDialog1:=TOpenDialog.Create(nil);
try
OpenDialog1.Filter := 'Only Text files (*.txt)|*.txt';
if OpenDialog1.Execute then
ShowMessage('Selected File '+OpenDialog1.FileName);
finally
OpenDialog1.Free;
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With