我正在使用delphi,当我执行openpicturedialog时,我想要一个目录的所有文件的列表.
i.e.,When open dialog is executed and
i select one file from it,I want the
list of all files from the directory
of selected file.
解决方法
@Himadri,OpenPictureDialog的主要目标不是选择一个目录,反正如果你使用这个对话框的另一个目的,你可以试试这个代码.
Var Path : String; SR : TSearchRec; DirList : TStrings; begin if OpenPictureDialog1.Execute then begin Path:=ExtractFileDir(OpenPictureDialog1.FileName); //Get the path of the selected file DirList:=TStringList.Create; try if FindFirst(Path + '*.*',faArchive,SR) = 0 then begin repeat DirList.Add(SR.Name); //Fill the list until FindNext(SR) <> 0; FindClose(SR); end; //do your stuff finally DirList.Free; end; end; end;