如何得到D盘上所有扩展名为DOC的文件呢?哪位给一个算法和例程?谢谢!!!!
时间:2011-10-17
来源:互联网
如何得到D盘上所有扩展名为DOC的文件呢?哪位给一个算法和例程?谢谢!!!!
作者: billrobin 发布时间: 2011-10-17
看帮助,FindFirst,FindNext
作者: bdmh 发布时间: 2011-10-17
Delphi(Pascal) code
function FindFile(Path: string): string; {搜索文件夹和文件} var Sr: TSearchRec; CommaList: TStringList; s: string; dt: TDateTime; begin commalist := Tstringlist.Create; CommaList.Add('DIRLIST'); try Findfirst(path + '*.*', faAnyFile, sr); if ((Sr.Attr and faDirectory) > 0) and (Sr.Name <> '.') then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('*' + s + sr.name); end; while findnext(sr) = 0 do begin if ((Sr.Attr and faDirectory) > 0) and (Sr.Name <> '..') then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('*' + s + sr.name); end; end; FindClose(sr); FindFirst(path + '*.*', faArchive + faReadOnly + faHidden + faSysFile, Sr); if Sr.Attr <> faDirectory then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('\' + s+ Format('%.0n', [sr.Size / 1]) + '|' + sr.name); end; //Inttostr( while findnext(sr) = 0 do begin if (sr.Attr <> faDirectory) then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('\' + s +Format('%.0n', [sr.Size / 1]) + '|' + sr.name); end; end; FindClose(Sr); except end; Result := commalist.Text; //Result是消息的 定义 commalist.Free; end; *.*换成*.doc,整个驱动盘会很慢
作者: shuaialang 发布时间: 2011-10-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28