如何在选择目录后得到目录内的文件名(在线等待) (20分)

  • 主题发起人 charles2002
  • 开始时间
C

charles2002

Unregistered / Unconfirmed
GUEST, unregistred user!
我用SelectDirectory打开选择目录窗口,但不知如何取得目录内的文件
就象winmap选择歌曲目录一样
 
这个..... 自己编一个函数不就ok了? 就是字符串的操作呗。
 
??selectdirectory只能选择目录,还能选择文件么?
 
搞错了吧,这是选择目录的。
 
用 findFirst 这一组函数:

The following example uses an edit control, a button, a string grid, and seven check boxes. The check boxes correspond to the seven possible file attributes. When the button is clicked, the path specified in the edit control is searched for files matching the checked file attributes. The names and sizes of the matching files are inserted into the string grid.

procedure TForm1.Button1Click(Sender: TObject);

var
sr: TSearchRec;
FileAttrs: Integer;
begin
StringGrid1.RowCount := 1;
if CheckBox1.Checked then
FileAttrs := faReadOnly
else
FileAttrs := 0;
if CheckBox2.Checked then
FileAttrs := FileAttrs + faHidden;
if CheckBox3.Checked then
FileAttrs := FileAttrs + faSysFile;
if CheckBox4.Checked then
FileAttrs := FileAttrs + faVolumeID;
if CheckBox5.Checked then

FileAttrs := FileAttrs + faDirectory;
if CheckBox6.Checked then
FileAttrs := FileAttrs + faArchive;
if CheckBox7.Checked then

FileAttrs := FileAttrs + faAnyFile;

if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then

begin
with StringGrid1 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
Cells[1,RowCount-1] := sr.Name;
Cells[2,RowCount-1] := IntToStr(sr.Size);
end;
while FindNext(sr) = 0 do
begin
if (sr.Attr and FileAttrs) = sr.Attr then
begin
RowCount := RowCount + 1;
Cells[1, RowCount-1] := sr.Name;

Cells[2, RowCount-1] := IntToStr(sr.Size);
end;
end;
FindClose(sr);
end;
end;
end;
 
不行呀,急,各位大哥帮帮忙呀
 
最简单的方法就是放上一个TFileListbox
 
影子兄:
有什么办法可删除其后缀呢?
 
放上一个ListBox。用StrRScan搜索'.',删除后缀后添加到ListBox中
 
接受答案了.
 
顶部