FlavioMacedo Posted December 15, 2017 Share Posted December 15, 2017 I need to display the contents of a directory in a frame for the user to choose the file and save the path in an edit. Does anyone have any ideas or examples of how to do this? Quote Link to comment Share on other sites More sharing options...
mierlp Posted December 15, 2017 Share Posted December 15, 2017 Hi I use a uniListbox for that with the following functions/code : function FindFiles(searchstr: string; list: TStrings): boolean; var hn: THandle; fd: WIN32_FIND_DATA; begin Result := False; hn := FindFirstFile(PChar(searchstr),fd); if hn <> INVALID_HANDLE_VALUE then begin Result := True; list.Add(StrPas(fd.cFileName)); while FindNextFile(hn,fd) = True do list.Add(StrPas(fd.cFileName)); end; Windows.FindClose(hn); end; On the form activate the uniLisbox is filled with the names of pdf files procedure TFormExplorAccreditation.UniFormActivate(Sender: TObject); begin UniListBox_Files.Items.Clear; FindFiles(uniServerModule.StartPath+'\files\pdf\'+'*.pdf',UniListBox_Files.Items); end; When the user double clicks on a file name you can use/do something with the file, in thiscase a var will be used and gets the selected file name sSenderFILE := UniListBox_files.Items[uniListBox_Files.ItemIndex]; for extract the directory you can use ExtractFilePath function, but in you case you already knowthe directory name because you need the show the content of a given directory 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.