Delphi里用什么能得到某一目录下所有文件名?

nancy_song 2002-04-10 01:42:47
我的这个目录下只有文件而无子目录。
...全文
22 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
nancy_song 2002-04-10
  • 打赏
  • 举报
回复
谢谢各位!
nancy_song 2002-04-10
  • 打赏
  • 举报
回复
谢谢你!
eagle123 2002-04-10
  • 打赏
  • 举报
回复
这两个一定是前两个,直接跳过就行了,或者用SearchRec.Name[1]<>′.′判断 用filesetattr(filename,faarchive)去掉所有特殊属性
zx_wang 2002-04-10
  • 打赏
  • 举报
回复
1.if rc.name <> '.' or rc.name <> '..' then
2.
procedure TFMForm.Properties1Click(Sender: TObject);
var
Attributes, NewAttributes: Word;
begin
with FileAttrForm do
begin
FileDirName.Caption := FileList.Items[FileList.ItemIndex];
{ set box caption }
PathName.Caption := FileList.Directory;
{ show directory name }
ChangeDate.Caption :=
DateTimeToStr(FileDateToDateTime(FileAge(FileList.FileName)));
Attributes := FileGetAttr(FileDirName.Caption);
{ read file attributes }
ReadOnly.Checked := (Attributes and faReadOnly) = faReadOnly;
Archive.Checked := (Attributes and faArchive) = faArchive;
System.Checked := (Attributes and faSysFile) = faSysFile;
Hidden.Checked := (Attributes and faHidden) = faHidden;
if ShowModal <> id_Cancel then { execute dialog box }
begin
NewAttributes := Attributes;
{ start with original attributes }
if ReadOnly.Checked then
NewAttributes := NewAttributes or faReadOnly
else
NewAttributes := NewAttributes andnot faReadOnly;
if Archive.Checked then
NewAttributes := NewAttributes or faArchive
else
NewAttributes := NewAttributes andnot faArchive;
if System.Checked then
NewAttributes := NewAttributes or faSysFile
else
NewAttributes := NewAttributes andnot faSysFile;
if Hidden.Checked then
NewAttributes := NewAttributes or faHidden
else
NewAttributes := NewAttributes andnot faHidden;
if NewAttributes <> Attributes then { if anything changed... }
FileSetAttr(FileDirName.Caption, NewAttributes);
{ ...write the new values }
end;
end;
end;
nancy_song 2002-04-10
  • 打赏
  • 举报
回复
那怎么跳过这两个?
怎么设置文件属性为非隐藏?
zx_wang 2002-04-10
  • 打赏
  • 举报
回复
这是因为DOS有两个
1. .
2. ..
nancy_song 2002-04-10
  • 打赏
  • 举报
回复
var
rc:TSearchRec;

用findfirst('c:\ling\*.*',faAnyFile,rc);
我知道此目录下肯定有文件存在。
为什么rc.name的返回值是'.'?
nancy_song 2002-04-10
  • 打赏
  • 举报
回复
还有我想删除此目录下的所有文件呢>?
用DELETEFILE?
nancy_song 2002-04-10
  • 打赏
  • 举报
回复
还有一个问题,work中怎样设置页的行数和每行字数?
johnmack 2002-04-10
  • 打赏
  • 举报
回复
TFileListBox能列出本目录下所有文件
用它的Items属性能得到所有文件名


newwen 2002-04-10
  • 打赏
  • 举报
回复
findfirst,findnext,findclose,TSearchRec
其实用 TFileListBox。filelist最简单

zx_wang 2002-04-10
  • 打赏
  • 举报
回复
findfirst、findnext

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧