问旁启题描述:
使用delphi如何生成一个目录(包括子目录)的文件列表呢,就象一些播放器那样,指定一个运皮如目录,就可以把目录及子目录下所有的音乐文件添加到列表里.
解析:
function FileList(Path: stringAttr: Integer = FAAnyfile): TStrings
var
SR: TSearchRec
begin
Result := TStringList.Create
if Path[Length(Path)] <>'\' then
Path := Path + '\'
if (Attr and FADirectory) <>FADirectory then
Attr := Attr or FADirectory
if FindFirst(Path + '*.*', Attr, SR) = 0 then
repeat
if (SR.Attr and FADirectory) = FADirectory then begin
if (SR.Name <>'.') and (SR.Name <>'..') then
Result.AddStrings(FileList(Path + SR.Name))
end
else
Result.Add(Path + SR.Name)
until FindNext(SR) <>0
FindClose(SR)
end
一种是,将如喊数据库文件路径设置成,当前程序下的目录+data\db1.mdb二是每次调用openPictureDailog1后用chdir()渣举野改回当前程序目录
即:chdir(extractfilepath(paramstr(0)))
第一种答肆可以窗口创建事件中用:extractfilepath(paramstr(0))+data\db1.mdb作为数据库文件路径
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)