FindAllFiles function and Listbox1 lazarus / 62-General ---------------------------------------------------------------------- mpknap · 2020-08-16 19:10 I get the names of the files from a folder using the FindAllFiles function, display them in listbox1. It's easy. I have a problem how to do that after clicking on a file name in LISTBOX, the PATH for this file will be displayed Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  GetDir(0, S);ChDir(s + '\credo-data-export\detections');   jsonFiles := FindAllFiles('', '*.json', False);  try     listbox1.Items := jsonFiles;  finally  jsonFiles.Free;   end; ChDir(s); ---------------------------------------------------------------------- Handoko · 2020-08-16 19:22 You can try TFileListBox, which can be found in the Misc tab. And then you can set the Directory and Mask properties to what you want. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, Forms, Controls, FileCtrl, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    FileListBox1: TFileListBox;    procedure Button1Click(Sender: TObject);  private  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  FileListBox1.Directory := '/Data';  FileListBox1.Mask := '*.pas';end; end. ---------------------------------------------------------------------- mpknap · 2020-08-16 19:37 Thanks . I'll take advantage of this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, Forms, Controls, FileCtrl, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    FileListBox1: TFileListBox;    Label1: TLabel;  procedure Button1Click(Sender: TObject);    procedure FileListBox1Click(Sender: TObject);  private  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  FileListBox1.Directory := 'C:\DataCenter\PythonScript';  FileListBox1.Mask := '*.pas';end; procedure TForm1.FileListBox1Click(Sender: TObject);begin   label1.Caption:=FileListBox1.Directory;end; end. ---------------------------------------------------------------------- Bart · 2020-08-16 19:49 Quote from: mpknap on August 16, 2020, 09:10:21 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  GetDir(0, S);ChDir(s + '\credo-data-export\detections');   jsonFiles := FindAllFiles('', '*.json', False); No need for the ChDir's. Just do a FindAllFiles('.\credo-data-export\detections'); GetDir(0,S) will get you the current directory, and so wil prepending the path with '.\'. Bart